
<!DOCTYPE HTML>
<html lang="zh-hans" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>13.16适配flutter_badge_plus · Flutter for Harmony教程</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        <meta name="author" content="坚果派">
        
        
    
    <link rel="stylesheet" href="../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-splitter/splitter.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-tbfed-pagefooter/footer.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-expandable-chapters/expandable-chapters.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-chapter-fold/chapter-fold.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-back-to-top-button/plugin.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-code/plugin.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-pageview-count/plugin.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-search-plus/search.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-emphasize/plugin.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-forkmegithub/plugin.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-theme-lou/lou.css">
                
            
        

    

    
        
        <link rel="stylesheet" href="../styles/website.css">
        
    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="12.14适配flutter_native_contact_picker_plus.html" />
    
    
    <link rel="prev" href="12.12适配battey_level_plus.html" />
    

    </head>
    <body>
         
<div class="donate-modal modal">
  <div class="modal-header">
    <div>
      <span>
        <img
          id="modal-avatar"
          class="modal-avatar"
          src="http://xkapp-uat.oss-cn-hangzhou.aliyuncs.com/2e7a3f70-80ab-4b50-93ec-a04dfeef949b/avatar-100.png"
        />
      </span>
      <span id="nickname"> breeze </span>
      <p class="modal-close close" onclick="closeDonateModal()">×</p>
    </div>
    <div class="message">
      <div class="tip">
        <i></i>
        <span>随意打赏，但不要超过一顿早餐钱 💕</span>
      </div>
    </div>
  </div>
  <div class="modal-content">
    <div class="modal-pay-way">
      <div id="wxpay" onclick="showDonateImg(0)">
        <input
          type="radio"
          name="pay-way"
          value="wxpay"
          class="zs-type"
          checked="checked"
        />
        <span>
          <img
            id="wxpay-logo"
            src=""
          />
        </span>
      </div>
      <div id="alipay" onclick="showDonateImg(1)">
        <input type="radio" name="pay-way" value="alipay" class="zs-type" />
        <span>
          <img
            id="alipay-logo"
            src=""
          />
        </span>
      </div>
    </div>
    <div class="modal-pay-qrcode">
      <img id="wxpay-code" src="https://luckly007.oss-cn-beijing.aliyuncs.com/img/image-20210922202901895.png" />
      <img
        id="alipay-code"
        src="https://luckly007.oss-cn-beijing.aliyuncs.com/img/image-20210922202843746.png"
        hidden
      />
    </div>
  </div>
</div>
<div class="mask"></div>


<div class="book">
  <div class="header-inner">
    <!-- LOGO -->
    <div class="logo"></div>
    <span class="title"></span>

    <!-- Search -->
    
<div id="book-search-input" role="search">
    <input type="text" placeholder="输入并搜索" />
</div>


    <!-- Nav -->
    <ul class="header-nav">
      <li>
        <a href="https://www.nutpi.net/" target="_blank">坚果派官网</a>
      </li><li>
        <a href="https://www.arkui.club/" target="_blank">ArkUI实战</a>
      </li><li>
        <a href="https://space.bilibili.com/480883651" target="_blank">哔哩哔哩</a>
      </li><li>
        <a href="https://gitcode.com/nutpi" target="_blank">GitCode</a>
      </li>
    </ul>
  </div>

  <div class="book-summary">
    <div class="book-summary-title">文档目录</div>
     
    <nav role="navigation">


<ul class="summary">
    
    

    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="../">
            
                <a href="../">
            
                    
                    1.前言
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="../坚果派介绍.html">
            
                <a href="../坚果派介绍.html">
            
                    
                    2.坚果派介绍
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="../chapter2/">
            
                <a href="../chapter2/">
            
                    
                    3.Flutter鸿蒙化
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.3.1" data-path="../chapter1/01Flutter介绍.html">
            
                <a href="../chapter1/01Flutter介绍.html">
            
                    
                    3.1 Flutter介绍
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.2" data-path="../chapter1/02HarmonyOS与OpenHarmony介绍.html">
            
                <a href="../chapter1/02HarmonyOS与OpenHarmony介绍.html">
            
                    
                    3.2 背景与原理
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.3" data-path="../chapter1/02功能开发.html">
            
                <a href="../chapter1/02功能开发.html">
            
                    
                    3.3 功能开发
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.4" data-path="../chapter1/03Flutter_Engine编译.html">
            
                <a href="../chapter1/03Flutter_Engine编译.html">
            
                    
                    3.4 Flutter Engine编译
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.5" data-path="../chapter1/03FutterEntry使用.html">
            
                <a href="../chapter1/03FutterEntry使用.html">
            
                    
                    3.5 FutterEntry使用
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.6" data-path="../chapter1/04性能调优.html">
            
                <a href="../chapter1/04性能调优.html">
            
                    
                    3.6 性能调优
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.7" data-path="../chapter1/05OHOS平台适配flutter三方库.html">
            
                <a href="../chapter1/05OHOS平台适配flutter三方库.html">
            
                    
                    3.7 OHOS平台适配flutter三方库
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.8" data-path="../chapter1/06如何使用_Flutter_Channel.html">
            
                <a href="../chapter1/06如何使用_Flutter_Channel.html">
            
                    
                    3.8 如何使用Flutter Channel
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.9" data-path="../chapter1/07开发Flutter静态库.html">
            
                <a href="../chapter1/07开发Flutter静态库.html">
            
                    
                    3.9 开发Flutter静态库
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.10" data-path="../chapter1/FAQ.html">
            
                <a href="../chapter1/FAQ.html">
            
                    
                    3.10 FAQ
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.11" data-path="../chapter1/服务.html">
            
                <a href="../chapter1/服务.html">
            
                    
                    3.11 服务
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.12" data-path="../chapter1/资料整理.html">
            
                <a href="../chapter1/资料整理.html">
            
                    
                    3.12 资料整理
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.13" data-path="../chapter2/2.3Impeller渲染引擎.html">
            
                <a href="../chapter2/2.3Impeller渲染引擎.html">
            
                    
                    3.13 Impeller渲染引擎
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="../chapter3/">
            
                <a href="../chapter3/">
            
                    
                    4.Flutter与Dart介绍
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.4.1" data-path="../chapter3/3.1Flutter介绍.html">
            
                <a href="../chapter3/3.1Flutter介绍.html">
            
                    
                    4.1 Flutter介绍
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.2" data-path="../chapter3/3.2Dart介绍.html">
            
                <a href="../chapter3/3.2Dart介绍.html">
            
                    
                    4.2 Dart介绍
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.5" data-path="../chapter4/">
            
                <a href="../chapter4/">
            
                    
                    5.HarmonyOS/OpenHarmony与ArkTS介绍
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.5.1" data-path="../chapter4/4.1HarmonyOS.html">
            
                <a href="../chapter4/4.1HarmonyOS.html">
            
                    
                    5.1 HarmonyOS
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.2" data-path="../chapter4/4.2OpenHarmony.html">
            
                <a href="../chapter4/4.2OpenHarmony.html">
            
                    
                    5.2 OpenHarmony
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.3" data-path="../chapter4/4.3HarmonyOSNEXT.html">
            
                <a href="../chapter4/4.3HarmonyOSNEXT.html">
            
                    
                    5.3 HarmonyOS NEXT
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.4" data-path="../chapter4/4.4ArkTS语言_.html">
            
                <a href="../chapter4/4.4ArkTS语言_.html">
            
                    
                    5.4 ArkTS语言
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.5" data-path="../chapter4/4.5三者的差异.html">
            
                <a href="../chapter4/4.5三者的差异.html">
            
                    
                    5.5 三者的区别与联系
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.6" data-path="../chapter4/4.6从开发者视角看_uniapp_与_Flutter_的差异.html">
            
                <a href="../chapter4/4.6从开发者视角看_uniapp_与_Flutter_的差异.html">
            
                    
                    5.6 从开发者视角看uniapp与Flutter的差异
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.6" data-path="../chapter5/">
            
                <a href="../chapter5/">
            
                    
                    6.鸿蒙Flutter开发环境配置
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.6.1" data-path="../chapter5/5.1windows环境配置.html">
            
                <a href="../chapter5/5.1windows环境配置.html">
            
                    
                    6.1 Windows环境配置
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.2" data-path="../chapter5/5.2mac环境配置.md">
            
                <span>
            
                    
                    6.2 Mac环境配置
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.3" data-path="../chapter5/5.2mac环境配置3.32.html">
            
                <a href="../chapter5/5.2mac环境配置3.32.html">
            
                    
                    6.3 Mac环境配置3.32版本
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.4" data-path="../chapter5/5.3使用_FlutterSDK_3.22.1.html">
            
                <a href="../chapter5/5.3使用_FlutterSDK_3.22.1.html">
            
                    
                    6.4 使用FlutterSDK 3.22.1
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.5" data-path="../chapter5/5.4第一个鸿蒙Flutter应用程序.html">
            
                <a href="../chapter5/5.4第一个鸿蒙Flutter应用程序.html">
            
                    
                    6.5 第一个鸿蒙Flutter应用程序
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.6" data-path="../chapter5/5.5鸿蒙Flutter运行到多平台.html">
            
                <a href="../chapter5/5.5鸿蒙Flutter运行到多平台.html">
            
                    
                    6.6 运行到多平台
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.7" data-path="../chapter5/5.5Mac环境Java配置指南.html">
            
                <a href="../chapter5/5.5Mac环境Java配置指南.html">
            
                    
                    6.7 Mac环境Java配置指南
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.8" data-path="../chapter5/5.6使用最新的fluttersdk配置开发环境.html">
            
                <a href="../chapter5/5.6使用最新的fluttersdk配置开发环境.html">
            
                    
                    6.8 使用最新FlutterSDK配置开发环境
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.9" data-path="../chapter5/5.7OpenHarmony设备运行指导.html">
            
                <a href="../chapter5/5.7OpenHarmony设备运行指导.html">
            
                    
                    6.9 OpenHarmony设备运行指导
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.10" data-path="../chapter5/5.8现有项目支持鸿蒙.html">
            
                <a href="../chapter5/5.8现有项目支持鸿蒙.html">
            
                    
                    6.10 现有Flutter项目支持鸿蒙
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.11" data-path="../chapter5/5.9鸿蒙版Flutter仓库变更.html">
            
                <a href="../chapter5/5.9鸿蒙版Flutter仓库变更.html">
            
                    
                    6.11 鸿蒙版Flutter仓库变更
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.12" data-path="../chapter5/5.10真机与模拟器.html">
            
                <a href="../chapter5/5.10真机与模拟器.html">
            
                    
                    6.12 真机与模拟器
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.13" data-path="../chapter5/5.11使用fvm.html">
            
                <a href="../chapter5/5.11使用fvm.html">
            
                    
                    6.13 使用FVM管理
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.14" data-path="../chapter5/5.12Ma环境FVM安裝指南.html">
            
                <a href="../chapter5/5.12Ma环境FVM安裝指南.html">
            
                    
                    6.14 Mac环境FVM安装指南
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.15" data-path="../chapter5/5.12使用3.27.4构建鸿蒙应用.html">
            
                <a href="../chapter5/5.12使用3.27.4构建鸿蒙应用.html">
            
                    
                    6.15 使用3.27.4构建鸿蒙应用
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.16" data-path="../chapter5/5.13使用_Flutter_SDK_3.27.4构建HarmonyOS应用.html">
            
                <a href="../chapter5/5.13使用_Flutter_SDK_3.27.4构建HarmonyOS应用.html">
            
                    
                    6.16 使用Flutter SDK 3.27.4构建HarmonyOS应用
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.17" data-path="../chapter5/5.14Flutter-OH版本演进规划和分支策略.html">
            
                <a href="../chapter5/5.14Flutter-OH版本演进规划和分支策略.html">
            
                    
                    6.17 Flutter-OH版本演进规划和分支策略
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.18" data-path="../chapter5/5.15mac环境配置3.22版本.html">
            
                <a href="../chapter5/5.15mac环境配置3.22版本.html">
            
                    
                    6.18 mac环境配置3.22版本
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.7" data-path="../chapter6/">
            
                <a href="../chapter6/">
            
                    
                    7.在鸿蒙应用中添加Flutter页面
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.7.1" data-path="../chapter6/6.1如何使用FlutterPage.html">
            
                <a href="../chapter6/6.1如何使用FlutterPage.html">
            
                    
                    7.1 如何使用FlutterPage
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.2" data-path="../chapter6/6.2如何使用混合开发添加跳转_FlutterEntry.html">
            
                <a href="../chapter6/6.2如何使用混合开发添加跳转_FlutterEntry.html">
            
                    
                    7.2 如何使用混合开发添加跳转FlutterEntry
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.3" data-path="../chapter6/6.3在鸿蒙应用中添加Flutter页面.html">
            
                <a href="../chapter6/6.3在鸿蒙应用中添加Flutter页面.html">
            
                    
                    7.3 在鸿蒙应用中添加Flutter页面
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.8" data-path="../chapter7/">
            
                <a href="../chapter7/">
            
                    
                    8.Flutter与HarmonyOS混合开发进阶
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.8.1" data-path="../chapter7/7.1如何使用_FlutterPage.md">
            
                <span>
            
                    
                    8.1 如何使用FlutterPage
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.2" data-path="../chapter7/7.2如何使用混合开发添加跳转_FlutterEntry.md">
            
                <span>
            
                    
                    8.2 如何使用混合开发添加跳转FlutterEntry
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.3" data-path="../chapter7/7.3_harmonyos添加flutter页面跳转时路由的处理.html">
            
                <a href="../chapter7/7.3_harmonyos添加flutter页面跳转时路由的处理.html">
            
                    
                    8.3 harmonyos添加flutter页面跳转时路由的处理
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.4" data-path="../chapter7/7.4使用FlutterChannel实现和Flutter和HarmonyOS交互.html">
            
                <a href="../chapter7/7.4使用FlutterChannel实现和Flutter和HarmonyOS交互.html">
            
                    
                    8.4 使用FlutterChannel实现和Flutter和HarmonyOS交互
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.9" data-path="../chapter8/">
            
                <a href="../chapter8/">
            
                    
                    9.在鸿蒙应用中使用Flutter Channel能力
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.9.1" data-path="../chapter8/8.1如何使用混合开发_module.html">
            
                <a href="../chapter8/8.1如何使用混合开发_module.html">
            
                    
                    9.1 如何使用混合开发module
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.2" data-path="../chapter8/8.2如何使用混合开发添加跳转_FlutterEntry.html">
            
                <a href="../chapter8/8.2如何使用混合开发添加跳转_FlutterEntry.html">
            
                    
                    9.2 如何使用混合开发添加跳转FlutterEntry
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.3" data-path="../chapter8/8.3如何使用lutter和鸿蒙next混合渲染.html">
            
                <a href="../chapter8/8.3如何使用lutter和鸿蒙next混合渲染.html">
            
                    
                    9.3 如何使用Flutter和鸿蒙NEXT混合渲染
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.4" data-path="../chapter8/8.4_混合渲染开发实践:以scan_三方库为例.html">
            
                <a href="../chapter8/8.4_混合渲染开发实践:以scan_三方库为例.html">
            
                    
                    9.4 混合渲染开发实践：以fluttertpc_scan三方库为例
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.5" data-path="../chapter8/8.5如何使用Flutter与鸿蒙通信_FlutterChannel.html">
            
                <a href="../chapter8/8.5如何使用Flutter与鸿蒙通信_FlutterChannel.html">
            
                    
                    9.5 如何使用Flutter与鸿蒙通信FlutterChannel
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.6" data-path="../chapter8/8.7Har包模式引入.html">
            
                <a href="../chapter8/8.7Har包模式引入.html">
            
                    
                    9.6 Har包模式引入
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.7" data-path="../chapter8/8.7源码模式引入.html">
            
                <a href="../chapter8/8.7源码模式引入.html">
            
                    
                    9.7 源码模式引入
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.8" data-path="../chapter8/8.8初始化Flutter.html">
            
                <a href="../chapter8/8.8初始化Flutter.html">
            
                    
                    9.8 初始化Flutter
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.9" data-path="../chapter8/8.9跳转Flutter页面.html">
            
                <a href="../chapter8/8.9跳转Flutter页面.html">
            
                    
                    9.9 跳转Flutter页面
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.10" data-path="../chapter9/">
            
                <a href="../chapter9/">
            
                    
                    10.与原生混合渲染
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.10.1" data-path="../chapter9/9.1flutter鸿蒙化背景.html">
            
                <a href="../chapter9/9.1flutter鸿蒙化背景.html">
            
                    
                    10.1 Flutter鸿蒙化背景
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10.2" data-path="../chapter9/9.1外接纹理适配.html">
            
                <a href="../chapter9/9.1外接纹理适配.html">
            
                    
                    10.2 Flutter OHOS外接纹理适配简介
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10.3" data-path="../chapter9/9.2如何使用多引擎_FlutterEngineGroup.html">
            
                <a href="../chapter9/9.2如何使用多引擎_FlutterEngineGroup.html">
            
                    
                    10.3 如何使用多引擎FlutterEngineGroup
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10.4" data-path="../chapter9/9.3如何使用PlatformView.html">
            
                <a href="../chapter9/9.3如何使用PlatformView.html">
            
                    
                    10.4 如何使用PlatformView
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10.5" data-path="../chapter9/9.4PlatformView同层渲染方案适配切换指导.html">
            
                <a href="../chapter9/9.4PlatformView同层渲染方案适配切换指导.html">
            
                    
                    10.5 PlatformView同层渲染方案适配切换指导
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.11" data-path="../chapter10/">
            
                <a href="../chapter10/">
            
                    
                    11.开发Flutter静态库
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.11.1" data-path="../chapter10/10.1开发module.html">
            
                <a href="../chapter10/10.1开发module.html">
            
                    
                    11.1开发module
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.2" data-path="../chapter10/10.2开发package.html">
            
                <a href="../chapter10/10.2开发package.html">
            
                    
                    11.2开发package
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.3" data-path="../chapter10/10.3开发plugin.html">
            
                <a href="../chapter10/10.3开发plugin.html">
            
                    
                    11.3开发plugin
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.4" data-path="../chapter10/10.4开发FFI_plugin.html">
            
                <a href="../chapter10/10.4开发FFI_plugin.html">
            
                    
                    11.4开发FFI plugin
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.12" data-path="../chapter11/">
            
                <a href="../chapter11/">
            
                    
                    12.Packages使用指南
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.12.1" data-path="../chapter11/11.1高效使用_Packages指南.html">
            
                <a href="../chapter11/11.1高效使用_Packages指南.html">
            
                    
                    12.1高效使用Packages指南
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.2" data-path="../chapter11/11.2发布Packages.html">
            
                <a href="../chapter11/11.2发布Packages.html">
            
                    
                    12.2发布Packages
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.3" data-path="../chapter11/11.3使用fvm管理.html">
            
                <a href="../chapter11/11.3使用fvm管理.html">
            
                    
                    12.3使用fvm管理
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.13" data-path="./">
            
                <a href="./">
            
                    
                    13.鸿蒙适配Flutter三方库
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.13.1" data-path="12.1纯dart库无需迁移.html">
            
                <a href="12.1纯dart库无需迁移.html">
            
                    
                    13.1纯dart库无需迁移
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.13.2" data-path="12.2坚果派已适配的库.html">
            
                <a href="12.2坚果派已适配的库.html">
            
                    
                    13.2坚果派目前适配三方库进展
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.13.3" data-path="12.3适配三方库之FlutterToast.html">
            
                <a href="12.3适配三方库之FlutterToast.html">
            
                    
                    13.3适配三方库之FlutterToast
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.13.4" data-path="12.4适配三方库之udid.html">
            
                <a href="12.4适配三方库之udid.html">
            
                    
                    13.4适配三方库之udid
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.13.5" data-path="12.5适配torch_light.html">
            
                <a href="12.5适配torch_light.html">
            
                    
                    13.5适配torch_light
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.13.6" data-path="12.6适配flutter_native_contact_picker.html">
            
                <a href="12.6适配flutter_native_contact_picker.html">
            
                    
                    13.6适配flutter_native_contact_picker
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.13.7" data-path="12.7适配flutter_timezone.html">
            
                <a href="12.7适配flutter_timezone.html">
            
                    
                    13.7适配flutter_timezone
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.13.8" data-path="12.8适配flutter_exit_app.html">
            
                <a href="12.8适配flutter_exit_app.html">
            
                    
                    13.8适配flutter_exit_app
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.13.9" data-path="12.9适配flutter_phone_direct_caller.html">
            
                <a href="12.9适配flutter_phone_direct_caller.html">
            
                    
                    13.9适配flutter_phone_direct_caller
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.13.10" data-path="12.10适配flutter_app_icon_badge.html">
            
                <a href="12.10适配flutter_app_icon_badge.html">
            
                    
                    13.10适配flutter_app_icon_badge
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.13.11" data-path="12.10适配screen_capture_event.html">
            
                <a href="12.10适配screen_capture_event.html">
            
                    
                    13.11适配screen_capture_event
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.13.12" data-path="12.10适配screenshot_callback.html">
            
                <a href="12.10适配screenshot_callback.html">
            
                    
                    13.12适配screenshot_callback
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.13.13" data-path="12.11适配memory_info.html">
            
                <a href="12.11适配memory_info.html">
            
                    
                    13.13适配memory_info
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.13.14" data-path="12.11适配screen_brightness.html">
            
                <a href="12.11适配screen_brightness.html">
            
                    
                    13.14适配screen_brightness
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.13.15" data-path="12.12适配battey_level_plus.html">
            
                <a href="12.12适配battey_level_plus.html">
            
                    
                    13.15适配battey_level_plus
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="1.13.16" data-path="12.13适配flutter_badge_plus.html">
            
                <a href="12.13适配flutter_badge_plus.html">
            
                    
                    13.16适配flutter_badge_plus
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.13.17" data-path="12.14适配flutter_native_contact_picker_plus.html">
            
                <a href="12.14适配flutter_native_contact_picker_plus.html">
            
                    
                    13.17适配flutter_native_contact_picker_plus
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.13.18" data-path="12.15获取设备随机存取存储器_(RAM">
            
                <span>
            
                    
                    13.18获取设备随机存取存储器 (RAM) 大小
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.13.19" data-path="12.16适配system_info_plus.html">
            
                <a href="12.16适配system_info_plus.html">
            
                    
                    13.19适配system_info_plus
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.13.20" data-path="12.17适配app_badge_plus.html">
            
                <a href="12.17适配app_badge_plus.html">
            
                    
                    13.20适配app_badge_plus
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.13.21" data-path="12.18适配flutter_native_contact_picker_plus.md">
            
                <span>
            
                    
                    13.21适配flutter_native_contact_picker_plus
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.13.22" data-path="12.19device_info_plus插件适配.html">
            
                <a href="12.19device_info_plus插件适配.html">
            
                    
                    13.22device_info_plus插件适配
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.13.23" data-path="12.20package_info_plus.html">
            
                <a href="12.20package_info_plus.html">
            
                    
                    13.23package_info_plus
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.13.24" data-path="12.21NetworkInfo适配.html">
            
                <a href="12.21NetworkInfo适配.html">
            
                    
                    13.24NetworkInfo适配
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.13.25" data-path="12.22url_luacher适配指南.html">
            
                <a href="12.22url_luacher适配指南.html">
            
                    
                    13.25url_luacher适配指南
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.13.26" data-path="di.html">
            
                <a href="di.html">
            
                    
                    13.26依赖注入
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.14" data-path="../chapter13/">
            
                <a href="../chapter13/">
            
                    
                    14.性能优化与调试
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.14.1" data-path="../chapter13/13.1环境配置.html">
            
                <a href="../chapter13/13.1环境配置.html">
            
                    
                    14.1 环境配置
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.14.2" data-path="../chapter13/13.2Flutter_开发鸿蒙应用时三方库引入指南.html">
            
                <a href="../chapter13/13.2Flutter_开发鸿蒙应用时三方库引入指南.html">
            
                    
                    14.2 Flutter开发鸿蒙应用时三方库引入指南
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.14.3" data-path="../chapter13/13.2性能分析定界指南.html">
            
                <a href="../chapter13/13.2性能分析定界指南.html">
            
                    
                    14.3 性能分析定界指南
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.14.4" data-path="../chapter13/13.3梳理线程顺序.html">
            
                <a href="../chapter13/13.3梳理线程顺序.html">
            
                    
                    14.4 性能分析第一步-梳理线程顺序
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.14.5" data-path="../chapter13/13.4滑动响应时延.html">
            
                <a href="../chapter13/13.4滑动响应时延.html">
            
                    
                    14.5 性能分析-滑动响应时延
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.14.6" data-path="../chapter13/13.5帧渲染跟踪.html">
            
                <a href="../chapter13/13.5帧渲染跟踪.html">
            
                    
                    14.6 性能分析-帧渲染跟踪
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.14.7" data-path="../chapter13/13.6如何调试代码.html">
            
                <a href="../chapter13/13.6如何调试代码.html">
            
                    
                    14.7 如何调试代码
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.14.8" data-path="../chapter13/13.7在_Flutter_中实现鸿蒙平台引入_package，其他平台排除.html">
            
                <a href="../chapter13/13.7在_Flutter_中实现鸿蒙平台引入_package，其他平台排除.html">
            
                    
                    14.8 在Flutter中实现鸿蒙平台引入package，其他平台排除
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.14.9" data-path="../chapter13/运行.html">
            
                <a href="../chapter13/运行.html">
            
                    
                    14.9 运行
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.15" data-path="../chapter14/">
            
                <a href="../chapter14/">
            
                    
                    15.迁移实战
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.15.1" data-path="../chapter14/14.1拨打电话.html">
            
                <a href="../chapter14/14.1拨打电话.html">
            
                    
                    15.1 拨打电话
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.15.2" data-path="../chapter14/14.2使用url_launcher.html">
            
                <a href="../chapter14/14.2使用url_launcher.html">
            
                    
                    15.2 使用url_launcher
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.15.3" data-path="../chapter14/14.3flutter开发鸿蒙PC应用.html">
            
                <a href="../chapter14/14.3flutter开发鸿蒙PC应用.html">
            
                    
                    15.3 flutter开发鸿蒙PC应用
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.15.4" data-path="../chapter14/14.4探索适用于鸿蒙原生应用的跨平台开发框架.html">
            
                <a href="../chapter14/14.4探索适用于鸿蒙原生应用的跨平台开发框架.html">
            
                    
                    15.4 探索适用于鸿蒙原生应用的跨平台开发框架
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.15.5" data-path="../chapter14/14.5保存图片.html">
            
                <a href="../chapter14/14.5保存图片.html">
            
                    
                    15.5 保存图片
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.15.6" data-path="../chapter14/14.6使用url.html">
            
                <a href="../chapter14/14.6使用url.html">
            
                    
                    15.6 使用url
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.15.7" data-path="../chapter14/今日时鉴.html">
            
                <a href="../chapter14/今日时鉴.html">
            
                    
                    15.7 今日时鉴
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.16" data-path="../chapter15/">
            
                <a href="../chapter15/">
            
                    
                    16.上架审核
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.16.1" data-path="../chapter15/15.1应用上架流程.html">
            
                <a href="../chapter15/15.1应用上架流程.html">
            
                    
                    16.1应用上架流程
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.16.2" data-path="../chapter15/15.2审核注意事项.html">
            
                <a href="../chapter15/15.2审核注意事项.html">
            
                    
                    16.2审核注意事项
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.17" data-path="../chapter16/">
            
                <a href="../chapter16/">
            
                    
                    17.FAQ
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.17.1" data-path="../chapter16/16.1ohos应用编译相关问题.html">
            
                <a href="../chapter16/16.1ohos应用编译相关问题.html">
            
                    
                    17.1 ohos应用编译相关问题
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.17.2" data-path="../chapter16/16.2原有项目迁移鸿蒙.html">
            
                <a href="../chapter16/16.2原有项目迁移鸿蒙.html">
            
                    
                    17.2 原有项目迁移鸿蒙
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.17.3" data-path="../chapter16/16.3权限相关.html">
            
                <a href="../chapter16/16.3权限相关.html">
            
                    
                    17.3 权限相关
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.17.4" data-path="../chapter16/16.4Flutter_3.22.0-ohos_0.1.0_Release发布.html">
            
                <a href="../chapter16/16.4Flutter_3.22.0-ohos_0.1.0_Release发布.html">
            
                    
                    17.4 Flutter 3.22.0-ohos 0.1.0 Release发布
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.17.5" data-path="../chapter16/16.5环境相关问题.html">
            
                <a href="../chapter16/16.5环境相关问题.html">
            
                    
                    17.5 环境相关问题
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.17.6" data-path="../chapter16/16.6ohos代码开发相关问题.html">
            
                <a href="../chapter16/16.6ohos代码开发相关问题.html">
            
                    
                    17.6 ohos代码开发相关问题
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.17.7" data-path="../chapter16/16.7解析flutter相关的cppcrash堆栈.html">
            
                <a href="../chapter16/16.7解析flutter相关的cppcrash堆栈.html">
            
                    
                    17.7 解析flutter相关的cppcrash堆栈
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.17.8" data-path="../chapter16/16.8ohos引擎产物编译相关问题.html">
            
                <a href="../chapter16/16.8ohos引擎产物编译相关问题.html">
            
                    
                    17.8 ohos引擎产物编译相关问题
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.17.9" data-path="../chapter16/ffi.html">
            
                <a href="../chapter16/ffi.html">
            
                    
                    17.9 FFI
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.17.10" data-path="../chapter16/三方库相关.html">
            
                <a href="../chapter16/三方库相关.html">
            
                    
                    17.10 三方库相关
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.18" data-path="../chapter17/">
            
                <a href="../chapter17/">
            
                    
                    18.阅读更多
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.18.1" data-path="../chapter17/17.1版本.html">
            
                <a href="../chapter17/17.1版本.html">
            
                    
                    18.1 适配HarmonyOS Next API16的鸿蒙版Flutter 3.22.0版本发布
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.18.2" data-path="../chapter17/17.2平台判断与问题处理指南.html">
            
                <a href="../chapter17/17.2平台判断与问题处理指南.html">
            
                    
                    18.2 平台判断与问题处理指南
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.18.3" data-path="../chapter17/17.3鸿蒙版Flutter_3.22.0版本正式发布(1.0Release">
            
                <span>
            
                    
                    18.3 鸿蒙版Flutter 3.22.0版本正式发布(1.0Release)
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.18.4" data-path="../chapter17/17.4优化_ohos_构建过程.html">
            
                <a href="../chapter17/17.4优化_ohos_构建过程.html">
            
                    
                    18.4 优化ohos构建过程
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.18.5" data-path="../chapter17/17.5新增use-application-binary命令.html">
            
                <a href="../chapter17/17.5新增use-application-binary命令.html">
            
                    
                    18.5 新增use-application-binary命令
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.18.6" data-path="../chapter17/17.6Flutter_3.22.0-ohos_1.0.1_Release发布.md">
            
                <span>
            
                    
                    18.6 Flutter 3.22.0-ohos 1.0.1 Release发布
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.18.7" data-path="../chapter17/17.7关于插件参数传递.html">
            
                <a href="../chapter17/17.7关于插件参数传递.html">
            
                    
                    18.7 关于插件参数传递
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.18.8" data-path="../chapter17/17.8关于鸿蒙版Flutter的_context_.html">
            
                <a href="../chapter17/17.8关于鸿蒙版Flutter的_context_.html">
            
                    
                    18.8 关于鸿蒙版Flutter的context
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.18.9" data-path="../chapter17/5.1API_18正式发布.html">
            
                <a href="../chapter17/5.1API_18正式发布.html">
            
                    
                    18.9 5.1API 18正式发布
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.18.10" data-path="../chapter17/5.1完整.html">
            
                <a href="../chapter17/5.1完整.html">
            
                    
                    18.10 5.1完整
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.19" data-path="../chapter18/">
            
                <a href="../chapter18/">
            
                    
                    19.多设备能力
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.19.1" data-path="../chapter18/18.1多设备自适应布局.html">
            
                <a href="../chapter18/18.1多设备自适应布局.html">
            
                    
                    19.1 自适应布局
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.19.2" data-path="../chapter18/18.2多设备响应式布局.html">
            
                <a href="../chapter18/18.2多设备响应式布局.html">
            
                    
                    19.2 响应式布局
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.19.3" data-path="../chapter18/18.3多设备典型布局场景.html">
            
                <a href="../chapter18/18.3多设备典型布局场景.html">
            
                    
                    19.3 典型布局场景
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.19.4" data-path="../chapter18/18.4交互归一能力.html">
            
                <a href="../chapter18/18.4交互归一能力.html">
            
                    
                    19.4 交互归一能力
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.20" data-path="../chapter19/README.md">
            
                <span>
            
                    
                    20.关于未来
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.21" data-path="../chapter20/">
            
                <a href="../chapter20/">
            
                    
                    21.版本更新
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.21.1" data-path="../chapter20/20.1鸿蒙版Flutter_3.22.0版本正式发布(1.0Release">
            
                <span>
            
                    
                    21.1 鸿蒙版Flutter 3.22.0版本正式发布(1.0Release)
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.21.2" data-path="../chapter20/20.2Flutter_3.22.0-ohos_1.0.1_Release发布.html">
            
                <a href="../chapter20/20.2Flutter_3.22.0-ohos_1.0.1_Release发布.html">
            
                    
                    21.2 Flutter 3.22.0-ohos 1.0.1 Release发布
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.21.3" data-path="../chapter20/20.3发布新版本.html">
            
                <a href="../chapter20/20.3发布新版本.html">
            
                    
                    21.3 发布新版本
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.21.4" data-path="../chapter20/20.4Flutter3.22.0-ohos-1.0.4发布.html">
            
                <a href="../chapter20/20.4Flutter3.22.0-ohos-1.0.4发布.html">
            
                    
                    21.4 Flutter3.22.0-ohos-1.0.4发布
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.21.5" data-path="../chapter20/20.5如何升级插件升级最新的鸿蒙版_flutter.html">
            
                <a href="../chapter20/20.5如何升级插件升级最新的鸿蒙版_flutter.html">
            
                    
                    21.5 如何升级插件升级最新的鸿蒙版flutter
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.21.6" data-path="../chapter20/20.6各版本的鸿蒙版flutter如何获取.html">
            
                <a href="../chapter20/20.6各版本的鸿蒙版flutter如何获取.html">
            
                    
                    21.6 各版本的鸿蒙版flutter如何获取
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.21.7" data-path="../chapter20/20.7新版本发布.html">
            
                <a href="../chapter20/20.7新版本发布.html">
            
                    
                    21.7 新版本发布
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.22" data-path="../致谢.html">
            
                <a href="../致谢.html">
            
                    
                    致谢
            
                </a>
            

            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            本书使用 GitBook 发布
        </a>
    </li>
</ul>

</nav>
     
  </div>

  <!-- Content nav -->
  <div class="book-anchor">
    <div class="book-anchor-title"></div>

    <div class="book-anchor-body"></div>
  </div>

  <div class="book-body">
    
    <div class="body-inner">
       

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href=".." >13.16适配flutter_badge_plus</a>
    </h1>
</div>



      <div class="page-wrapper" tabindex="-1" role="main">
        <div class="page-inner">
          
<div class="search-plus" id="book-search-results">
    <div class="search-noresults">
    
          <section class="normal markdown-section">
             <h2 id="flutter&#x5230;&#x9E3F;&#x8499;&#x7684;&#x8DE8;&#x8D8A;&#xFF1A;flutterappiconbadge&#x5E93;&#x7684;&#x9E3F;&#x8499;&#x9002;&#x914D;&#x4E4B;&#x65C5;">Flutter&#x5230;&#x9E3F;&#x8499;&#x7684;&#x8DE8;&#x8D8A;&#xFF1A;flutter_app_icon_badge&#x5E93;&#x7684;&#x9E3F;&#x8499;&#x9002;&#x914D;&#x4E4B;&#x65C5;</h2>
<p>&#x672C;&#x9879;&#x76EE;&#x4F5C;&#x8005;&#xFF1A;&#x575A;&#x679C;</p>
<p>&#x60A8;&#x53EF;&#x4EE5;&#x4F7F;&#x7528;&#x8FD9;&#x4E2A;<a href="https://flutter.io/" target="_blank">Flutter</a>&#x63D2;&#x4EF6;&#x6765;&#x66F4;&#x6539;&#x5E94;&#x7528;&#x7A0B;&#x5E8F;&#x56FE;&#x6807;&#x4E0A;&#x7684;&#x89D2;&#x6807;</p>
<p>&#x4F5C;&#x8005;&#x4ED3;&#x5E93;&#xFF1A;<a href="https://github.com/badver/flutter_app_icon_badge/" target="_blank">https://github.com/badver/flutter_app_icon_badge/</a></p>
<p>&#x5728;&#x6570;&#x5B57;&#x5316;&#x6D6A;&#x6F6E;&#x7684;&#x63A8;&#x52A8;&#x4E0B;&#xFF0C;&#x8DE8;&#x5E73;&#x53F0;&#x5F00;&#x53D1;&#x6846;&#x67B6;&#x5982; Flutter &#x51ED;&#x501F;&#x5176;&#x9AD8;&#x6548;&#x3001;&#x4FBF;&#x6377;&#x7684;&#x7279;&#x6027;&#xFF0C;&#x6210;&#x4E3A;&#x4E86;&#x5F00;&#x53D1;&#x8005;&#x4EEC;&#x7684;&#x5BA0;&#x513F;&#x3002;&#x800C;&#x9E3F;&#x8499;&#x7CFB;&#x7EDF;&#x7684;&#x5D1B;&#x8D77;&#xFF0C;&#x66F4;&#x662F;&#x4E3A;&#x8DE8;&#x5E73;&#x53F0;&#x5F00;&#x53D1;&#x6CE8;&#x5165;&#x4E86;&#x65B0;&#x7684;&#x6D3B;&#x529B;&#x3002;&#x4E3A;&#x4E86;&#x52A9;&#x529B;&#x5F00;&#x53D1;&#x8005;&#x5728;&#x9E3F;&#x8499;&#x751F;&#x6001;&#x4E2D;&#x5FEB;&#x901F;&#x5B9E;&#x73B0; flutter_app_icon_badge&#x66F4;&#x6539;&#x5E94;&#x7528;&#x7A0B;&#x5E8F;&#x56FE;&#x6807;&#x4E0A;&#x7684;&#x89D2;&#x6807;&#x529F;&#x80FD;&#xFF0C;&#x672C;&#x6587;&#x5C06;&#x6DF1;&#x5165;&#x6D45;&#x51FA;&#x5730;&#x4E3A;&#x5927;&#x5BB6;&#x89E3;&#x6790;&#x5982;&#x4F55;&#x9002;&#x914D; flutter_app_icon_badge &#x4E09;&#x65B9;&#x5E93;&#x81F3;&#x9E3F;&#x8499;&#x5E73;&#x53F0;&#x3002;</p>
<h2 id="&#x4E00;&#x3001;&#x9002;&#x914D;&#x9E3F;&#x8499;&#x7248;-flutterappiconbadge-&#x4E09;&#x65B9;&#x5E93;">&#x4E00;&#x3001;&#x9002;&#x914D;&#x9E3F;&#x8499;&#x7248; flutter_app_icon_badge &#x4E09;&#x65B9;&#x5E93;</h2>
<h3 id="&#xFF08;&#x4E00;&#xFF09;&#x7248;&#x672C;&#x9009;&#x62E9;&#x4E0E;&#x4ED3;&#x5E93;&#x7B80;&#x4ECB;">&#xFF08;&#x4E00;&#xFF09;&#x7248;&#x672C;&#x9009;&#x62E9;&#x4E0E;&#x4ED3;&#x5E93;&#x7B80;&#x4ECB;</h3>
<p>&#x6211;&#x4EEC;&#x5148;&#x53BB; pub &#x4E0A;&#x67E5;&#x770B;&#x6700;&#x65B0;&#x7248;&#x672C;&#xFF0C;&#x6211;&#x4EEC;&#x9009;&#x62E9;&#x4EE5; 0.0.10&#x7248;&#x672C;&#x4E3A;&#x57FA;&#x7840;&#x8FDB;&#x884C;&#x9002;&#x914D;&#x3002;flutter_app_icon_badge &#x662F;&#x4E00;&#x4E2A;&#x7528;&#x4E8E;&#x5728; Flutter &#x5E94;&#x7528;&#x4E2D;&#x66F4;&#x6539;&#x5E94;&#x7528;&#x7A0B;&#x5E8F;&#x56FE;&#x6807;&#x4E0A;&#x7684;&#x89D2;&#x6807;&#x529F;&#x80FD;&#xFF0C;&#x5176; GitHub &#x4ED3;&#x5E93;&#x4E3A;<a href="https://github.com/badver/flutter_app_icon_badge/" target="_blank">https://github.com/badver/flutter_app_icon_badge/</a> &#xFF0C;&#x6211;&#x4EEC;&#x7684;&#x76EE;&#x6807;&#x662F;&#x5C06;&#x8FD9;&#x4E2A;&#x63D2;&#x4EF6;&#x9002;&#x914D;&#x5230;&#x9E3F;&#x8499;&#x5E73;&#x53F0;&#x3002;</p>
<h3 id="&#xFF08;&#x4E8C;&#xFF09;&#x5F15;&#x5165;&#x80CC;&#x666F;&#x4E0E;&#x4F7F;&#x7528;&#x573A;&#x666F;">&#xFF08;&#x4E8C;&#xFF09;&#x5F15;&#x5165;&#x80CC;&#x666F;&#x4E0E;&#x4F7F;&#x7528;&#x573A;&#x666F;</h3>
<p>&#x5728; OpenHarmony &#x5317;&#x5411;&#x751F;&#x6001;&#x7684;&#x53D1;&#x5C55;&#x8FC7;&#x7A0B;&#x4E2D;&#xFF0C;&#x8BB8;&#x591A;&#x5DF2;&#x7ECF;&#x9002;&#x914D;&#x4E86; Flutter &#x7684;&#x5382;&#x5546;&#x5728;&#x63A5;&#x5165; OpenHarmony &#x65F6;&#xFF0C;&#x90FD;&#x5E0C;&#x671B;&#x80FD;&#x591F;&#x7EE7;&#x7EED;&#x4F7F;&#x7528; FlutterToast &#x6765;&#x5B9E;&#x73B0;&#x901A;&#x77E5;&#x529F;&#x80FD;&#x3002;&#x56E0;&#x6B64;&#xFF0C;&#x6211;&#x4EEC;&#x63D0;&#x4F9B;&#x4E86;&#x8FD9;&#x4E2A;&#x9002;&#x914D;&#x65B9;&#x6848;&#xFF0C;&#x91C7;&#x7528;&#x63D2;&#x4EF6;&#x5316;&#x7684;&#x9002;&#x914D;&#x5668;&#x6A21;&#x5F0F;&#xFF0C;&#x5E2E;&#x52A9;&#x751F;&#x6001;&#x4F19;&#x4F34;&#x5FEB;&#x901F;&#x5B9E;&#x73B0;&#x4EA7;&#x54C1;&#x5316;&#x3002;</p>
<p>&#x672C;&#x65B9;&#x6848;&#x9002;&#x7528;&#x4E8E;&#x5DF2;&#x7ECF;&#x652F;&#x6301; Flutter &#x6846;&#x67B6;&#x7684;&#x8BBE;&#x5907;&#x5728;&#x79FB;&#x690D;&#x5230; OpenHarmony &#x7CFB;&#x7EDF;&#x8FC7;&#x7A0B;&#x4E2D;&#xFF0C;&#x4F5C;&#x4E3A;&#x4E00;&#x4E2A;&#x5907;&#x9009;&#x65B9;&#x6848;&#x3002;</p>
<h3 id="&#xFF08;&#x4E09;&#xFF09;&#x4F7F;&#x7528;&#x6587;&#x6863;&#x4E0E;&#x63D2;&#x4EF6;&#x5E93;&#x4F7F;&#x7528;">&#xFF08;&#x4E09;&#xFF09;&#x4F7F;&#x7528;&#x6587;&#x6863;&#x4E0E;&#x63D2;&#x4EF6;&#x5E93;&#x4F7F;&#x7528;</h3>
<p>&#x9002;&#x914D; OpenHarmony &#x5E73;&#x53F0;&#x7684;&#x8BE6;&#x7EC6;&#x4F7F;&#x7528;&#x6307;&#x5BFC;&#x53EF;&#x4EE5;&#x53C2;&#x8003;&#xFF1A;<a href="https://gitcode.com/openharmony-sig/flutter_samples/blob/master/ohos/docs/07_plugin/ohos%E5%B9%B3%E5%8F%B0%E9%80%82%E9%85%8Dflutter%E4%B8%89%E6%96%B9%E5%BA%93%E6%8C%87%E5%AF%BC.md" target="_blank">Flutter&#x4F7F;&#x7528;&#x6307;&#x5BFC;&#x6587;&#x6863;</a></p>
<p>&#x5728;&#x9879;&#x76EE;&#x4E2D;&#x4F7F;&#x7528;&#x8BE5;&#x63D2;&#x4EF6;&#x5E93;&#x65F6;&#xFF0C;&#x53EA;&#x9700;&#x5728; <code>pubspec.yaml</code> &#x6587;&#x4EF6;&#x7684; <code>dependencies</code> &#x4E2D;&#x65B0;&#x589E;&#x5982;&#x4E0B;&#x914D;&#x7F6E;&#xFF1A;</p>
<pre><code class="lang-yaml"><span class="hljs-attr">dependencies:</span>
<span class="hljs-attr">  flutter_app_icon_badge:</span>
<span class="hljs-attr">    git:</span>
<span class="hljs-attr">      url:</span> <span class="hljs-string">&quot;https://gitcode.com/nutpi/flutter_app_icon_badge.git&quot;</span>
<span class="hljs-attr">      path:</span> <span class="hljs-string">&quot;&quot;</span>
</code></pre>
<p>&#x7136;&#x540E;&#x5728;&#x9879;&#x76EE;&#x6839;&#x76EE;&#x5F55;&#x8FD0;&#x884C; <code>flutter pub get</code>&#xFF0C;&#x5373;&#x53EF;&#x5B8C;&#x6210;&#x4F9D;&#x8D56;&#x6DFB;&#x52A0;</p>
<p>&#x63A5;&#x4E0B;&#x6765;&#x662F;&#x5177;&#x4F53;&#x7684;&#x9002;&#x914D;&#x8FC7;&#x7A0B;&#x3002;</p>
<h2 id="&#x4E8C;&#x3001;&#x9002;&#x914D;&#x8FC7;&#x7A0B;&#x8BE6;&#x89E3;">&#x4E8C;&#x3001;&#x9002;&#x914D;&#x8FC7;&#x7A0B;&#x8BE6;&#x89E3;</h2>
<h3 id="&#xFF08;&#x4E00;&#xFF09;&#x51C6;&#x5907;&#x5DE5;&#x4F5C;">&#xFF08;&#x4E00;&#xFF09;&#x51C6;&#x5907;&#x5DE5;&#x4F5C;</h3>
<p>&#x786E;&#x4FDD;&#x5DF2;&#x7ECF;&#x914D;&#x7F6E;&#x597D;&#x4E86; Flutter &#x5F00;&#x53D1;&#x73AF;&#x5883;&#xFF0C;&#x5177;&#x4F53;&#x53EF;&#x53C2;&#x8003; <a href="https://gitcode.com/openharmony-tpc/flutter_flutter/blob/master/README.md" target="_blank">Flutter &#x914D;&#x7F6E;&#x6307;&#x5357;</a>&#x3002;&#x540C;&#x65F6;&#xFF0C;&#x4ECE; <a href="https://pub.dev/" target="_blank">&#x5B98;&#x65B9;&#x63D2;&#x4EF6;&#x5E93;</a> &#x4E0B;&#x8F7D;&#x5F85;&#x9002;&#x914D;&#x7684;&#x4E09;&#x65B9;&#x63D2;&#x4EF6;&#x3002;&#x672C;&#x6307;&#x5BFC;&#x4E66;&#xFF0C; &#x4EE5;&#x9002;&#x914D; <a href="https://pub-web.flutter-io.cn/packages/flutter_app_icon_badge" target="_blank">flutter_app_icon_badge</a> &#x4E3A;&#x4F8B;</p>
<p><img src="https://nutpi-e41b.obs.cn-north-4.myhuaweicloud.com/image-20250417200546042.png" alt="image-20250417200546042"></p>
<h3 id="&#xFF08;&#x4E8C;&#xFF09;&#x63D2;&#x4EF6;&#x76EE;&#x5F55;&#x7ED3;&#x6784;">&#xFF08;&#x4E8C;&#xFF09;&#x63D2;&#x4EF6;&#x76EE;&#x5F55;&#x7ED3;&#x6784;</h3>
<p>&#x4E0B;&#x8F7D;&#x5E76;&#x89E3;&#x538B;&#x63D2;&#x4EF6;&#x540E;&#xFF0C;&#x6211;&#x4EEC;&#x4F1A;&#x770B;&#x5230;&#x4EE5;&#x4E0B;&#x76EE;&#x5F55;&#x7ED3;&#x6784;&#xFF1A;</p>
<ul>
<li><strong>lib</strong> &#xFF1A;&#x5BF9;&#x63A5; Dart &#x7AEF;&#x4EE3;&#x7801;&#x7684;&#x5165;&#x53E3;&#xFF0C;&#x7531;&#x6B64;&#x6587;&#x4EF6;&#x63A5;&#x6536;&#x5230;&#x53C2;&#x6570;&#x540E;&#xFF0C;&#x901A;&#x8FC7; channel &#x5C06;&#x6570;&#x636E;&#x53D1;&#x9001;&#x5230;&#x539F;&#x751F;&#x7AEF;&#x3002;</li>
<li><strong>android</strong> &#xFF1A;&#x5B89;&#x5353;&#x7AEF;&#x4EE3;&#x7801;&#x5B9E;&#x73B0;&#x76EE;&#x5F55;&#x3002;</li>
<li><strong>ios</strong> &#xFF1A;iOS &#x539F;&#x751F;&#x7AEF;&#x5B9E;&#x73B0;&#x76EE;&#x5F55;&#x3002;</li>
<li><strong>example</strong> &#xFF1A;&#x4E00;&#x4E2A;&#x4F9D;&#x8D56;&#x4E8E;&#x8BE5;&#x63D2;&#x4EF6;&#x7684; Flutter &#x5E94;&#x7528;&#x7A0B;&#x5E8F;&#xFF0C;&#x7528;&#x4E8E;&#x8BF4;&#x660E;&#x5982;&#x4F55;&#x4F7F;&#x7528;&#x5B83;&#x3002;</li>
<li><strong>README.md</strong> &#xFF1A;&#x4ECB;&#x7ECD;&#x5305;&#x7684;&#x6587;&#x4EF6;&#x3002;</li>
<li><strong>CHANGELOG.md</strong> &#xFF1A;&#x8BB0;&#x5F55;&#x6BCF;&#x4E2A;&#x7248;&#x672C;&#x4E2D;&#x7684;&#x66F4;&#x6539;&#x3002;</li>
<li><strong>LICENSE</strong> &#xFF1A;&#x5305;&#x542B;&#x8F6F;&#x4EF6;&#x5305;&#x8BB8;&#x53EF;&#x6761;&#x6B3E;&#x7684;&#x6587;&#x4EF6;&#x3002;</li>
</ul>
<h3 id="&#xFF08;&#x4E09;&#xFF09;&#x521B;&#x5EFA;&#x63D2;&#x4EF6;&#x7684;&#x9E3F;&#x8499;&#x6A21;&#x5757;">&#xFF08;&#x4E09;&#xFF09;&#x521B;&#x5EFA;&#x63D2;&#x4EF6;&#x7684;&#x9E3F;&#x8499;&#x6A21;&#x5757;</h3>
<p>&#x5728;&#x63D2;&#x4EF6;&#x76EE;&#x5F55;&#x4E0B;&#xFF0C;&#x6253;&#x5F00; Terminal&#xFF0C;&#x6267;&#x884C;&#x4EE5;&#x4E0B;&#x547D;&#x4EE4;&#x6765;&#x521B;&#x5EFA;&#x4E00;&#x4E2A;&#x9E3F;&#x8499;&#x5E73;&#x53F0;&#x7684; Flutter &#x6A21;&#x5757;&#xFF1A;</p>
<pre><code>flutter create . --org dev.badver.flutter_app_icon_badge --template=plugin --platforms=ohos
</code></pre><p>&#x6B65;&#x9AA4;&#xFF1A;</p>
<ol>
<li><p>&#x7528;vscode/trae&#x6253;&#x5F00;&#x521A;&#x521A;&#x4E0B;&#x8F7D;&#x597D;&#x7684;&#x63D2;&#x4EF6;&#x3002;</p>
</li>
<li><p>&#x6253;&#x5F00;Terminal&#xFF0C;cd&#x5230;&#x63D2;&#x4EF6;&#x76EE;&#x5F55;&#x4E0B;&#x3002;</p>
</li>
<li><p>&#x6267;&#x884C;&#x547D;&#x4EE4;<code>flutter create . --org dev.badver.flutter_app_icon_badge --template=plugin --platforms=ohos</code> &#x521B;&#x5EFA;&#x4E00;&#x4E2A;ohos&#x5E73;&#x53F0;&#x7684;flutter&#x6A21;&#x5757;&#x3002;</p>
</li>
</ol>
<p>&#x7B2C;&#x4E00;&#x4E2A;&#x95EE;&#x9898;&#xFF0C;&#x4FEE;&#x6539;sdk&#x7684;&#x7248;&#x672C;&#xFF0C;&#x9002;&#x914D;&#x65E7;&#x7248;&#x672C;&#x3002;</p>
<p>&#x6211;&#x4EEC;&#x505A;&#x597D;&#x4FEE;&#x6539;&#x5C31;&#x597D;&#x3002;</p>
<h3 id="&#xFF08;&#x56DB;&#xFF09;&#x5728;&#x6839;&#x76EE;&#x5F55;&#x4E0B;&#x6DFB;&#x52A0;&#x9E3F;&#x8499;&#x5E73;&#x53F0;&#x914D;&#x7F6E;">&#xFF08;&#x56DB;&#xFF09;&#x5728;&#x6839;&#x76EE;&#x5F55;&#x4E0B;&#x6DFB;&#x52A0;&#x9E3F;&#x8499;&#x5E73;&#x53F0;&#x914D;&#x7F6E;</h3>
<p>&#x5728;&#x9879;&#x76EE;&#x6839;&#x76EE;&#x5F55;&#x7684; <code>pubspec.yaml</code> &#x6587;&#x4EF6;&#x4E2D;&#xFF0C;&#x6DFB;&#x52A0;&#x9E3F;&#x8499;&#x5E73;&#x53F0;&#x7684;&#x76F8;&#x5173;&#x914D;&#x7F6E;&#xFF1A;</p>
<pre><code class="lang-yaml"><span class="hljs-attr">name:</span> flutter_app_icon_badge
<span class="hljs-attr">description:</span> Flutter app icon badge plugin to change the badge on the icon of your app.
<span class="hljs-attr">version:</span> <span class="hljs-number">2.0</span><span class="hljs-number">.0</span>
<span class="hljs-attr">homepage:</span> https://github.com/badver/flutter_app_icon_badge

<span class="hljs-attr">environment:</span>
<span class="hljs-attr">  sdk:</span> <span class="hljs-string">&apos;&gt;=2.12.0 &lt;4.0.0&apos;</span>
<span class="hljs-attr">  flutter:</span> <span class="hljs-string">&quot;&gt;=2.3.0&quot;</span>

<span class="hljs-attr">dependencies:</span>
<span class="hljs-attr">  flutter:</span>
<span class="hljs-attr">    sdk:</span> flutter

<span class="hljs-attr">dev_dependencies:</span>
<span class="hljs-attr">  flutter_test:</span>
<span class="hljs-attr">    sdk:</span> flutter

<span class="hljs-attr">flutter:</span>
<span class="hljs-attr">  plugin:</span>
<span class="hljs-attr">    platforms:</span>
<span class="hljs-attr">      android:</span>
<span class="hljs-attr">        package:</span> dev.badver.flutter_app_icon_badge
<span class="hljs-attr">        pluginClass:</span> FlutterAppIconBadgePlugin
<span class="hljs-attr">      ios:</span>
<span class="hljs-attr">        pluginClass:</span> FlutterAppIconBadgePlugin
<span class="hljs-attr">      linux:</span>
<span class="hljs-attr">        pluginClass:</span> FlutterAppIconBadgePlugin
<span class="hljs-attr">      macos:</span>
<span class="hljs-attr">        pluginClass:</span> FlutterAppIconBadgePlugin
<span class="hljs-attr">      windows:</span>
<span class="hljs-attr">        pluginClass:</span> FlutterAppIconBadgePlugin
<span class="hljs-attr">      ohos:</span>
<span class="hljs-attr">        package:</span> dev.badver.flutter_app_icon_badge
<span class="hljs-attr">        pluginClass:</span> FlutterAppIconBadgePlugin
</code></pre>
<h3 id="&#xFF08;&#x4E94;&#xFF09;&#x7F16;&#x5199;&#x9E3F;&#x8499;&#x63D2;&#x4EF6;&#x7684;&#x539F;&#x751F;-arkts&#x6A21;&#x5757;">&#xFF08;&#x4E94;&#xFF09;&#x7F16;&#x5199;&#x9E3F;&#x8499;&#x63D2;&#x4EF6;&#x7684;&#x539F;&#x751F; ArkTS&#x6A21;&#x5757;</h3>
<h4 id="1-&#x521B;&#x5EFA;&#x9E3F;&#x8499;&#x63D2;&#x4EF6;&#x6A21;&#x5757;">1. &#x521B;&#x5EFA;&#x9E3F;&#x8499;&#x63D2;&#x4EF6;&#x6A21;&#x5757;</h4>
<p>&#x4F7F;&#x7528; DevEco Studio &#x6253;&#x5F00;&#x9E3F;&#x8499;&#x9879;&#x76EE;&#x3002;</p>
<h4 id="2-&#x4FEE;&#x6539;&#x76F8;&#x5173;&#x914D;&#x7F6E;&#x6587;&#x4EF6;">2. &#x4FEE;&#x6539;&#x76F8;&#x5173;&#x914D;&#x7F6E;&#x6587;&#x4EF6;</h4>
<p>&#x5728; <code>ohos</code> &#x76EE;&#x5F55;&#x5185;&#x7684; <code>oh-package.json5</code> &#x6587;&#x4EF6;&#x4E2D;&#x6DFB;&#x52A0; <code>libs/flutter.har</code> &#x4F9D;&#x8D56;&#xFF0C;&#x5E76;&#x521B;&#x5EFA; <code>.gitignore</code> &#x6587;&#x4EF6;&#xFF0C;&#x6DFB;&#x52A0;&#x4EE5;&#x4E0B;&#x5185;&#x5BB9;&#x4EE5;&#x5FFD;&#x7565; <code>libs</code> &#x76EE;&#x5F55;&#xFF1A;</p>
<pre><code class="lang-json">/node_modules
/oh_modules
/local.properties
/.preview
/.idea
/build
/libs
*.har
/.cxx
/.test
/BuildProfile.ets
/oh-package-lock.json5
</code></pre>
<p><code>oh-package.json5</code> &#x6587;&#x4EF6;&#x5185;&#x5BB9;&#x5982;&#x4E0B;&#xFF1A;</p>
<pre><code class="lang-json">{
  <span class="hljs-string">&quot;name&quot;</span>: <span class="hljs-string">&quot;flutter_app_icon_badge&quot;</span>,
  <span class="hljs-string">&quot;version&quot;</span>: <span class="hljs-string">&quot;1.0.0&quot;</span>,
  <span class="hljs-string">&quot;description&quot;</span>: <span class="hljs-string">&quot;Flutter app icon badge plugin to change the badge on the icon of your app&quot;</span>,
  <span class="hljs-string">&quot;main&quot;</span>: <span class="hljs-string">&quot;index.ets&quot;</span>,
  <span class="hljs-string">&quot;author&quot;</span>: <span class="hljs-string">&quot;nutpi&quot;</span>,
  <span class="hljs-string">&quot;license&quot;</span>: <span class="hljs-string">&quot;Apache-2.0&quot;</span>,
  <span class="hljs-string">&quot;dependencies&quot;</span>: {
    <span class="hljs-string">&quot;@ohos/flutter_ohos&quot;</span>: <span class="hljs-string">&quot;file:./har/flutter.har&quot;</span>
  }
}
</code></pre>
<p>&#x5728; <code>ohos</code> &#x76EE;&#x5F55;&#x4E0B;&#x521B;&#x5EFA; <code>index.ets</code> &#x6587;&#x4EF6;&#xFF0C;&#x5BFC;&#x51FA;&#x914D;&#x7F6E;&#xFF1A;</p>
<pre><code class="lang-js">

<span class="hljs-keyword">import</span> FlutterAppIconBadgePlugin <span class="hljs-keyword">from</span> <span class="hljs-string">&apos;./src/main/ets/components/plugin/FlutterAppIconBadgePlugin&apos;</span>;
<span class="hljs-keyword">export</span> <span class="hljs-keyword">default</span> FlutterAppIconBadgePlugin;
</code></pre>
<h4 id="3-&#x7F16;&#x5199;-ets-&#x4EE3;&#x7801;">3. &#x7F16;&#x5199; ETS &#x4EE3;&#x7801;</h4>
<p>&#x6587;&#x4EF6;&#x7ED3;&#x6784;&#x548C;&#x4EE3;&#x7801;&#x903B;&#x8F91;&#x53EF;&#x4EE5;&#x53C2;&#x8003;&#x5B89;&#x5353;&#x6216; iOS &#x7684;&#x5B9E;&#x73B0;&#xFF0C;&#x9E3F;&#x8499;&#x7684; API &#x6587;&#x6863;&#x53EF;&#x4EE5;&#x53C2;&#x8003; &#xFF1A;<a href="https://developer.huawei.com/consumer/cn/doc/harmonyos-references/js-apis-notificationmanager" target="_blank">https://developer.huawei.com/consumer/cn/doc/harmonyos-references/js-apis-notificationmanager</a></p>
<p>ohos&#x7684;api&#x53EF;&#x4EE5;&#x53C2;&#x8003;&#xFF1A;<a href="https://gitcode.com/openharmony/docs" target="_blank">https://gitcode.com/openharmony/docs</a></p>
<p>&#x4EE5;&#x4E0B;&#x662F; <code>FlutterAppIconBadgePlugin.ets</code> &#x6587;&#x4EF6;&#x7684;&#x4EE3;&#x7801;&#x793A;&#x4F8B;&#xFF1A;</p>
<pre><code class="lang-js"><span class="hljs-keyword">import</span> {
  FlutterPlugin,
  FlutterPluginBinding,
  MethodCall,
  MethodCallHandler,
  MethodChannel,
  MethodResult,
} <span class="hljs-keyword">from</span> <span class="hljs-string">&apos;@ohos/flutter_ohos&apos;</span>;
<span class="hljs-keyword">import</span> { BusinessError } <span class="hljs-keyword">from</span> <span class="hljs-string">&apos;@kit.BasicServicesKit&apos;</span>;
<span class="hljs-keyword">import</span> { notificationManager } <span class="hljs-keyword">from</span> <span class="hljs-string">&apos;@kit.NotificationKit&apos;</span>;

<span class="hljs-comment">/** FlutterAppIconBadgePlugin **/</span>
<span class="hljs-keyword">export</span> <span class="hljs-keyword">default</span> <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">FlutterAppIconBadgePlugin</span> <span class="hljs-title">implements</span> <span class="hljs-title">FlutterPlugin</span>, <span class="hljs-title">MethodCallHandler</span> </span>{
  private channel: MethodChannel | <span class="hljs-literal">null</span> = <span class="hljs-literal">null</span>;

  <span class="hljs-keyword">constructor</span>() {
  }

  getUniqueClassName(): string {
    <span class="hljs-keyword">return</span> <span class="hljs-string">&quot;FlutterAppIconBadgePlugin&quot;</span>
  }

  onAttachedToEngine(binding: FlutterPluginBinding): <span class="hljs-keyword">void</span> {
    <span class="hljs-keyword">this</span>.channel = <span class="hljs-keyword">new</span> MethodChannel(binding.getBinaryMessenger(), <span class="hljs-string">&quot;flutter_app_icon_badge&quot;</span>);
    <span class="hljs-keyword">this</span>.channel.setMethodCallHandler(<span class="hljs-keyword">this</span>)
  }

  onDetachedFromEngine(binding: FlutterPluginBinding): <span class="hljs-keyword">void</span> {
    <span class="hljs-keyword">if</span> (<span class="hljs-keyword">this</span>.channel != <span class="hljs-literal">null</span>) {
      <span class="hljs-keyword">this</span>.channel.setMethodCallHandler(<span class="hljs-literal">null</span>)
    }
  }

  onMethodCall(call: MethodCall, result: MethodResult): <span class="hljs-keyword">void</span> {
    <span class="hljs-keyword">if</span> (call.method == <span class="hljs-string">&quot;updateBadge&quot;</span>) {
      <span class="hljs-keyword">try</span> {
        <span class="hljs-comment">// &#x83B7;&#x53D6;&#x53C2;&#x6570;</span>
        <span class="hljs-keyword">const</span> countArg :string= call.argument(<span class="hljs-string">&quot;count&quot;</span>);

        <span class="hljs-keyword">if</span> (countArg === <span class="hljs-literal">null</span> || countArg === <span class="hljs-literal">undefined</span>) {
          <span class="hljs-built_in">console</span>.error(<span class="hljs-string">&apos;Badge count argument is missing.&apos;</span>);
          result.error(<span class="hljs-string">&quot;MISSING_ARGUMENT&quot;</span>, <span class="hljs-string">&quot;Badge count argument is required.&quot;</span>, <span class="hljs-literal">null</span>);
          <span class="hljs-keyword">return</span>;
        }

        <span class="hljs-comment">// &#x786E;&#x4FDD; countArg &#x662F;&#x6570;&#x5B57;&#x7C7B;&#x578B;</span>
        <span class="hljs-keyword">let</span> badgeNumber: number = <span class="hljs-built_in">Number</span>(countArg);

        <span class="hljs-keyword">if</span> (<span class="hljs-built_in">isNaN</span>(badgeNumber)) {
          <span class="hljs-built_in">console</span>.error(<span class="hljs-string">&apos;Invalid badge number received:&apos;</span>, countArg);
          result.error(<span class="hljs-string">&quot;INVALID_ARGUMENT&quot;</span>, <span class="hljs-string">&quot;Badge count must be a number.&quot;</span>, <span class="hljs-literal">null</span>);
          <span class="hljs-keyword">return</span>;
        }

        notificationManager.setBadgeNumber(badgeNumber).then(() =&gt; {
          <span class="hljs-built_in">console</span>.info(<span class="hljs-string">`Succeeded in setting badge number to <span class="hljs-subst">${badgeNumber}</span>.`</span>);
          result.success(<span class="hljs-literal">null</span>);
        }).catch((err: BusinessError) =&gt; {
          <span class="hljs-built_in">console</span>.error(<span class="hljs-string">`Failed to set badge number. Code is <span class="hljs-subst">${err.code}</span>, message is <span class="hljs-subst">${err.message}</span>`</span>);
          result.error(err.code.toString(), err.message, <span class="hljs-literal">null</span>);
        });
      } <span class="hljs-keyword">catch</span> (e) {
        <span class="hljs-keyword">const</span> error = e <span class="hljs-keyword">as</span> <span class="hljs-built_in">Error</span>;
        <span class="hljs-built_in">console</span>.error(<span class="hljs-string">`Error processing updateBadge: <span class="hljs-subst">${error.message}</span>`</span>);
        result.error(<span class="hljs-string">&quot;UNKNOWN_ERROR&quot;</span>, error.message, <span class="hljs-literal">null</span>);
      }
    }
    <span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> (call.method == <span class="hljs-string">&quot;removeBadge&quot;</span>) {
      <span class="hljs-keyword">try</span> {
        notificationManager.setBadgeNumber(<span class="hljs-number">0</span>).then(() =&gt; {
          <span class="hljs-built_in">console</span>.info(<span class="hljs-string">`Succeeded in removing badge number.`</span>);
          result.success(<span class="hljs-literal">null</span>);
        }).catch((err: BusinessError) =&gt; {
          <span class="hljs-built_in">console</span>.error(<span class="hljs-string">`Failed to remove badge number. Code is <span class="hljs-subst">${err.code}</span>, message is <span class="hljs-subst">${err.message}</span>`</span>);
          result.error(err.code.toString(), err.message, <span class="hljs-literal">null</span>);
        });
      } <span class="hljs-keyword">catch</span> (e) {
        <span class="hljs-keyword">const</span> error = e <span class="hljs-keyword">as</span> <span class="hljs-built_in">Error</span>;
        <span class="hljs-built_in">console</span>.error(<span class="hljs-string">`Error processing removeBadge: <span class="hljs-subst">${error.message}</span>`</span>);
        result.error(<span class="hljs-string">&quot;UNKNOWN_ERROR&quot;</span>, error.message, <span class="hljs-literal">null</span>);
      }
    } <span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> (call.method == <span class="hljs-string">&quot;isAppBadgeSupported&quot;</span>) {
      <span class="hljs-comment">// &#x9E3F;&#x8499;&#x5E73;&#x53F0;&#x9ED8;&#x8BA4;&#x652F;&#x6301;&#x89D2;&#x6807;</span>
      result.success(<span class="hljs-literal">true</span>);
    } <span class="hljs-keyword">else</span> {
      result.notImplemented();
    }
  }
}
</code></pre>
<p>&#x8FD9;&#x91CC;&#x6211;&#x4E3B;&#x8981;&#x53C2;&#x8003;&#x7684;&#x662F;</p>
<h2 id="&#x4E09;&#x3001;notificationmanager&#x6A21;&#x5757;">&#x4E09;&#x3001;NotificationManager&#x6A21;&#x5757;</h2>
<p>&#x672C;&#x6A21;&#x5757;&#x63D0;&#x4F9B;&#x901A;&#x77E5;&#x7BA1;&#x7406;&#x7684;&#x80FD;&#x529B;&#xFF0C;&#x5305;&#x62EC;&#x53D1;&#x5E03;&#x3001;&#x53D6;&#x6D88;&#x53D1;&#x5E03;&#x901A;&#x77E5;&#xFF0C;&#x521B;&#x5EFA;&#x3001;&#x83B7;&#x53D6;&#x3001;&#x79FB;&#x9664;&#x901A;&#x77E5;&#x6E20;&#x9053;&#xFF0C;&#x83B7;&#x53D6;&#x901A;&#x77E5;&#x7684;&#x4F7F;&#x80FD;&#x72B6;&#x6001;&#x3001;&#x89D2;&#x6807;&#x4F7F;&#x80FD;&#x72B6;&#x6001;&#xFF0C;&#x83B7;&#x53D6;&#x901A;&#x77E5;&#x7684;&#x76F8;&#x5173;&#x4FE1;&#x606F;&#x7B49;&#x3002;</p>
<h3 id="1&#x5BFC;&#x5165;">1.&#x5BFC;&#x5165;</h3>
<pre><code class="lang-js"><span class="hljs-keyword">import</span> { notificationManager } <span class="hljs-keyword">from</span> <span class="hljs-string">&apos;@kit.NotificationKit&apos;</span>;
</code></pre>
<h3 id="2notificationmanagersetbadgenumber">2.notificationManager.setBadgeNumber</h3>
<p>setBadgeNumber(badgeNumber: number): Promise<void></void></p>
<p>&#x8BBE;&#x5B9A;&#x89D2;&#x6807;&#x4E2A;&#x6570;&#xFF0C;&#x5728;&#x5E94;&#x7528;&#x7684;&#x684C;&#x9762;&#x56FE;&#x6807;&#x4E0A;&#x5448;&#x73B0;&#x3002;&#x4F7F;&#x7528;Promise&#x5F02;&#x6B65;&#x56DE;&#x8C03;&#x3002;</p>
<p>&#x5F53;&#x89D2;&#x6807;&#x8BBE;&#x5B9A;&#x4E2A;&#x6570;&#x53D6;&#x503C;&#x5C0F;&#x4E8E;&#x6216;&#x7B49;&#x4E8E;0&#x65F6;&#xFF0C;&#x8868;&#x793A;&#x6E05;&#x9664;&#x89D2;&#x6807;&#x3002;&#x53D6;&#x503C;&#x5927;&#x4E8E;99&#x65F6;&#xFF0C;&#x901A;&#x77E5;&#x89D2;&#x6807;&#x5C06;&#x663E;&#x793A;99+&#x3002;</p>
<p><strong>&#x7CFB;&#x7EDF;&#x80FD;&#x529B;</strong>&#xFF1A;SystemCapability.Notification.Notification</p>
<p><strong>&#x53C2;&#x6570;&#xFF1A;</strong></p>
<table>
<thead>
<tr>
<th style="text-align:left">&#x53C2;&#x6570;&#x540D;</th>
<th style="text-align:left">&#x7C7B;&#x578B;</th>
<th style="text-align:left">&#x5FC5;&#x586B;</th>
<th style="text-align:left">&#x8BF4;&#x660E;</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">badgeNumber</td>
<td style="text-align:left">number</td>
<td style="text-align:left">&#x662F;</td>
<td style="text-align:left">&#x89D2;&#x6807;&#x4E2A;&#x6570;&#x3002;</td>
</tr>
</tbody>
</table>
<p><strong>&#x8FD4;&#x56DE;&#x503C;&#xFF1A;</strong></p>
<table>
<thead>
<tr>
<th style="text-align:left">&#x7C7B;&#x578B;</th>
<th style="text-align:left">&#x8BF4;&#x660E;</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">Promise<void></void></td>
<td style="text-align:left">&#x65E0;&#x8FD4;&#x56DE;&#x7ED3;&#x679C;&#x7684;Promise&#x5BF9;&#x8C61;&#x3002;</td>
</tr>
</tbody>
</table>
<p><strong>&#x9519;&#x8BEF;&#x7801;&#xFF1A;</strong></p>
<p>&#x4EE5;&#x4E0B;&#x9519;&#x8BEF;&#x7801;&#x7684;&#x8BE6;&#x7EC6;&#x4ECB;&#x7ECD;&#x8BF7;&#x53C2;&#x89C1;<a href="https://developer.huawei.com/consumer/cn/doc/harmonyos-references/errorcode-universal" target="_blank">&#x901A;&#x7528;&#x9519;&#x8BEF;&#x7801;</a>&#x548C;<a href="https://developer.huawei.com/consumer/cn/doc/harmonyos-references/errorcode-notification" target="_blank">&#x901A;&#x77E5;&#x9519;&#x8BEF;&#x7801;</a>&#x3002;</p>
<table>
<thead>
<tr>
<th style="text-align:left">&#x9519;&#x8BEF;&#x7801;ID</th>
<th style="text-align:left">&#x9519;&#x8BEF;&#x4FE1;&#x606F;</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">401</td>
<td style="text-align:left">Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.</td>
</tr>
<tr>
<td style="text-align:left">1600001</td>
<td style="text-align:left">Internal error.</td>
</tr>
<tr>
<td style="text-align:left">1600002</td>
<td style="text-align:left">Marshalling or unmarshalling error.</td>
</tr>
<tr>
<td style="text-align:left">1600003</td>
<td style="text-align:left">Failed to connect to the service.</td>
</tr>
<tr>
<td style="text-align:left">1600012</td>
<td style="text-align:left">No memory space.</td>
</tr>
</tbody>
</table>
<p><strong>&#x793A;&#x4F8B;&#xFF1A;</strong></p>
<pre><code class="lang-typescript"><span class="hljs-keyword">import</span> { BusinessError } from <span class="hljs-string">&apos;@kit.BasicServicesKit&apos;</span>;

<span class="hljs-keyword">let</span> badgeNumber: <span class="hljs-built_in">number</span> = <span class="hljs-number">10</span>;
notificationManager.setBadgeNumber(badgeNumber).then(() =&gt; {
  <span class="hljs-built_in">console</span>.info(<span class="hljs-string">`Succeeded in setting badge number.`</span>);
}).catch((err: BusinessError) =&gt; {
  <span class="hljs-built_in">console</span>.error(<span class="hljs-string">`Failed to set badge number. Code is <span class="hljs-subst">${err.code}</span>, message is <span class="hljs-subst">${err.message}</span>`</span>);
});
</code></pre>
<h3 id="3dart&#x7AEF;&#x662F;&#x8FD9;&#x6837;&#x5B9A;&#x4E49;&#x7684;">3.dart&#x7AEF;&#x662F;&#x8FD9;&#x6837;&#x5B9A;&#x4E49;&#x7684;</h3>
<pre><code class="lang-dart"><span class="hljs-keyword">import</span> <span class="hljs-string">&apos;dart:async&apos;</span>;

<span class="hljs-keyword">import</span> <span class="hljs-string">&apos;package:flutter/services.dart&apos;</span>;

<span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">FlutterAppIconBadge</span> </span>{
  <span class="hljs-keyword">static</span> <span class="hljs-keyword">const</span> MethodChannel _channel =
      <span class="hljs-keyword">const</span> MethodChannel(<span class="hljs-string">&apos;flutter_app_icon_badge&apos;</span>);

  <span class="hljs-comment"><span class="markdown">/// Change badge on app icon</span></span>
  <span class="hljs-keyword">static</span> Future&lt;<span class="hljs-keyword">void</span>&gt; updateBadge(<span class="hljs-built_in">int</span> count) <span class="hljs-keyword">async</span> {
    <span class="hljs-keyword">await</span> _channel.invokeMethod(<span class="hljs-string">&apos;updateBadge&apos;</span>, {<span class="hljs-string">&quot;count&quot;</span>: count});
  }

  <span class="hljs-comment"><span class="markdown">/// Remove badge on app icon</span></span>
  <span class="hljs-keyword">static</span> Future&lt;<span class="hljs-keyword">void</span>&gt; removeBadge() <span class="hljs-keyword">async</span> {
    <span class="hljs-keyword">await</span> _channel.invokeMethod(<span class="hljs-string">&apos;removeBadge&apos;</span>);
  }

  <span class="hljs-comment"><span class="markdown">/// Check if app badge is supported</span></span>
  <span class="hljs-keyword">static</span> Future&lt;<span class="hljs-built_in">bool</span>&gt; isAppBadgeSupported() <span class="hljs-keyword">async</span> {
    <span class="hljs-built_in">bool</span>? appBadgeSupported =
        <span class="hljs-keyword">await</span> _channel.invokeMethod(<span class="hljs-string">&apos;isAppBadgeSupported&apos;</span>);
    <span class="hljs-keyword">return</span> appBadgeSupported ?? <span class="hljs-keyword">false</span>;
  }

  <span class="hljs-comment"><span class="markdown">/// Check if app window is focused.</span></span>
  <span class="hljs-keyword">static</span> Future&lt;<span class="hljs-built_in">bool</span>&gt; isAppFocused() <span class="hljs-keyword">async</span> {
    <span class="hljs-built_in">bool</span>? isAppFocused = <span class="hljs-keyword">await</span> _channel.invokeMethod(<span class="hljs-string">&apos;isAppFocused&apos;</span>);
    <span class="hljs-keyword">return</span> isAppFocused ?? <span class="hljs-keyword">false</span>;
  }
}
</code></pre>
<h3 id="4ios&#x4FA7;&#x5904;&#x7406;">4.ios&#x4FA7;&#x5904;&#x7406;</h3>
<p>&#x7C7B;&#x4F3C;ios&#x4FA7;&#x5904;&#x7406;&#x8FD9;&#x8FB9;&#x7684;&#x4FE1;&#x606F;&#xFF0C;&#x5E76;&#x8FD4;&#x56DE;</p>
<pre><code class="lang-swift">    <span class="hljs-keyword">switch</span> call.method {
        <span class="hljs-keyword">case</span> <span class="hljs-string">&quot;updateBadge&quot;</span>:
          <span class="hljs-keyword">if</span> <span class="hljs-keyword">let</span> args = call.arguments <span class="hljs-keyword">as</span>? <span class="hljs-type">Dictionary</span>&lt;<span class="hljs-type">String</span>, <span class="hljs-type">Any</span>&gt;,
            <span class="hljs-keyword">let</span> <span class="hljs-built_in">count</span> = args[<span class="hljs-string">&quot;count&quot;</span>] <span class="hljs-keyword">as</span>? <span class="hljs-type">Int</span> {
            <span class="hljs-type">UIApplication</span>.shared.applicationIconBadgeNumber = <span class="hljs-built_in">count</span>
            result(<span class="hljs-literal">nil</span>)
          } <span class="hljs-keyword">else</span> {
            result(<span class="hljs-type">FlutterError</span>.<span class="hljs-keyword">init</span>(code: <span class="hljs-string">&quot;bad args&quot;</span>, message: <span class="hljs-literal">nil</span>, details: <span class="hljs-literal">nil</span>))
          }
        <span class="hljs-keyword">case</span> <span class="hljs-string">&quot;removeBadge&quot;</span>:
          <span class="hljs-type">UIApplication</span>.shared.applicationIconBadgeNumber = <span class="hljs-number">0</span>
          result(<span class="hljs-literal">nil</span>)
        <span class="hljs-keyword">case</span> <span class="hljs-string">&quot;isAppBadgeSupported&quot;</span>:
          result(<span class="hljs-literal">true</span>)
        <span class="hljs-keyword">default</span>:
          result(<span class="hljs-type">FlutterMethodNotImplemented</span>)
    }
</code></pre>
<h3 id="5arkts&#x5904;&#x7406;&#x56FE;&#x6807;">5.ArkTS&#x5904;&#x7406;&#x56FE;&#x6807;</h3>
<pre><code class="lang-swift"><span class="hljs-keyword">import</span> {
  <span class="hljs-type">FlutterPlugin</span>,
  <span class="hljs-type">FlutterPluginBinding</span>,
  <span class="hljs-type">MethodCall</span>,
  <span class="hljs-type">MethodCallHandler</span>,
  <span class="hljs-type">MethodChannel</span>,
  <span class="hljs-type">MethodResult</span>,
} from &apos;@ohos/flutter_ohos&apos;;
<span class="hljs-keyword">import</span> { BusinessError } from &apos;@kit.BasicServicesKit&apos;;
<span class="hljs-keyword">import</span> { notificationManager } from &apos;@kit.NotificationKit&apos;;

<span class="hljs-comment">/** FlutterAppIconBadgePlugin **/</span>
export <span class="hljs-keyword">default</span> <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">FlutterAppIconBadgePlugin</span> <span class="hljs-title">implements</span> <span class="hljs-title">FlutterPlugin</span>, <span class="hljs-title">MethodCallHandler</span> </span>{
  <span class="hljs-keyword">private</span> channel: <span class="hljs-type">MethodChannel</span> | null = null;

  constructor() {
  }

  getUniqueClassName(): string {
    <span class="hljs-keyword">return</span> <span class="hljs-string">&quot;FlutterAppIconBadgePlugin&quot;</span>
  }

  onAttachedToEngine(binding: <span class="hljs-type">FlutterPluginBinding</span>): void {
    this.channel = new <span class="hljs-type">MethodChannel</span>(binding.getBinaryMessenger(), <span class="hljs-string">&quot;flutter_app_icon_badge&quot;</span>);
    this.channel.setMethodCallHandler(this)
  }

  onDetachedFromEngine(binding: <span class="hljs-type">FlutterPluginBinding</span>): void {
    <span class="hljs-keyword">if</span> (this.channel != null) {
      this.channel.setMethodCallHandler(null)
    }
  }

  onMethodCall(call: <span class="hljs-type">MethodCall</span>, result: <span class="hljs-type">MethodResult</span>): void {
    <span class="hljs-keyword">if</span> (call.method == <span class="hljs-string">&quot;updateBadge&quot;</span>) {
      <span class="hljs-keyword">try</span> {
        <span class="hljs-comment">// &#x83B7;&#x53D6;&#x53C2;&#x6570;</span>
        const countArg :string= call.argument(<span class="hljs-string">&quot;count&quot;</span>);

        <span class="hljs-keyword">if</span> (countArg === null || countArg === undefined) {
          console.error(&apos;<span class="hljs-type">Badge</span> <span class="hljs-built_in">count</span> argument <span class="hljs-keyword">is</span> missing.&apos;);
          result.error(<span class="hljs-string">&quot;MISSING_ARGUMENT&quot;</span>, <span class="hljs-string">&quot;Badge count argument is required.&quot;</span>, null);
          <span class="hljs-keyword">return</span>;
        }

        <span class="hljs-comment">// &#x786E;&#x4FDD; countArg &#x662F;&#x6570;&#x5B57;&#x7C7B;&#x578B;</span>
        <span class="hljs-keyword">let</span> badgeNumber: number = <span class="hljs-type">Number</span>(countArg);

        <span class="hljs-keyword">if</span> (isNaN(badgeNumber)) {
          console.error(&apos;<span class="hljs-type">Invalid</span> badge number received:&apos;, countArg);
          result.error(<span class="hljs-string">&quot;INVALID_ARGUMENT&quot;</span>, <span class="hljs-string">&quot;Badge count must be a number.&quot;</span>, null);
          <span class="hljs-keyword">return</span>;
        }

        notificationManager.setBadgeNumber(badgeNumber).then(() =&gt; {
          console.info(`<span class="hljs-type">Succeeded</span> <span class="hljs-keyword">in</span> setting badge number to ${badgeNumber}.`);
          result.success(null);
        }).<span class="hljs-keyword">catch</span>((err: <span class="hljs-type">BusinessError</span>) =&gt; {
          console.error(`<span class="hljs-type">Failed</span> to <span class="hljs-keyword">set</span> badge number. <span class="hljs-type">Code</span> <span class="hljs-keyword">is</span> ${err.code}, message <span class="hljs-keyword">is</span> ${err.message}`);
          result.error(err.code.<span class="hljs-built_in">toString</span>(), err.message, null);
        });
      } <span class="hljs-keyword">catch</span> (e) {
        const error = e <span class="hljs-keyword">as</span> <span class="hljs-type">Error</span>;
        console.error(`<span class="hljs-type">Error</span> processing updateBadge: ${error.message}`);
        result.error(<span class="hljs-string">&quot;UNKNOWN_ERROR&quot;</span>, error.message, null);
      }
    }
    <span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> (call.method == <span class="hljs-string">&quot;removeBadge&quot;</span>) {
      <span class="hljs-keyword">try</span> {
        notificationManager.setBadgeNumber(<span class="hljs-number">0</span>).then(() =&gt; {
          console.info(`<span class="hljs-type">Succeeded</span> <span class="hljs-keyword">in</span> removing badge number.`);
          result.success(null);
        }).<span class="hljs-keyword">catch</span>((err: <span class="hljs-type">BusinessError</span>) =&gt; {
          console.error(`<span class="hljs-type">Failed</span> to remove badge number. <span class="hljs-type">Code</span> <span class="hljs-keyword">is</span> ${err.code}, message <span class="hljs-keyword">is</span> ${err.message}`);
          result.error(err.code.<span class="hljs-built_in">toString</span>(), err.message, null);
        });
      } <span class="hljs-keyword">catch</span> (e) {
        const error = e <span class="hljs-keyword">as</span> <span class="hljs-type">Error</span>;
        console.error(`<span class="hljs-type">Error</span> processing removeBadge: ${error.message}`);
        result.error(<span class="hljs-string">&quot;UNKNOWN_ERROR&quot;</span>, error.message, null);
      }
    } <span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> (call.method == <span class="hljs-string">&quot;isAppBadgeSupported&quot;</span>) {
      <span class="hljs-comment">// &#x9E3F;&#x8499;&#x5E73;&#x53F0;&#x9ED8;&#x8BA4;&#x652F;&#x6301;&#x89D2;&#x6807;</span>
      result.success(<span class="hljs-literal">true</span>);
    } <span class="hljs-keyword">else</span> {
      result.notImplemented();
    }
  }
}
</code></pre>
<h3 id="6&#x4F18;&#x5316;&#x901A;&#x77E5;">6.&#x4F18;&#x5316;&#x901A;&#x77E5;</h3>
<p><a href="https://developer.huawei.com/consumer/cn/doc/harmonyos-guides/notification-enable" target="_blank">&#x8BF7;&#x6C42;&#x901A;&#x77E5;&#x6743;&#x9650;</a></p>
<p>&#x5E94;&#x7528;&#x9700;&#x8981;&#x83B7;&#x53D6;&#x7528;&#x6237;&#x6388;&#x6743;&#x624D;&#x80FD;&#x53D1;&#x9001;&#x901A;&#x77E5;&#x3002;&#x5728;&#x901A;&#x77E5;&#x53D1;&#x5E03;&#x524D;&#x8C03;&#x7528;<a href="https://developer.huawei.com/consumer/cn/doc/harmonyos-references/js-apis-notificationmanager#notificationmanagerrequestenablenotification10-1" target="_blank">requestEnableNotification()</a>&#x65B9;&#x6CD5;&#xFF0C;&#x5F39;&#x7A97;&#x8BA9;&#x7528;&#x6237;&#x9009;&#x62E9;&#x662F;&#x5426;&#x5141;&#x8BB8;&#x53D1;&#x9001;&#x901A;&#x77E5;&#xFF0C;&#x540E;&#x7EED;&#x518D;&#x6B21;&#x8C03;&#x7528;<a href="https://developer.huawei.com/consumer/cn/doc/harmonyos-references/js-apis-notificationmanager#notificationmanagerrequestenablenotification10-1" target="_blank">requestEnableNotification()</a>&#x65B9;&#x6CD5;&#x65F6;&#xFF0C;&#x5219;&#x4E0D;&#x518D;&#x5F39;&#x7A97;&#x3002;</p>
<p>&#x901A;&#x77E5;&#x6388;&#x6743;&#x63A5;&#x53E3;&#x529F;&#x80FD;&#x4ECB;&#x7ECD;</p>
<table>
<thead>
<tr>
<th style="text-align:left"><strong>&#x63A5;&#x53E3;&#x540D;</strong></th>
<th style="text-align:left"><strong>&#x63CF;&#x8FF0;</strong></th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">isNotificationEnabled():Promise<boolean></boolean></td>
<td style="text-align:left">&#x67E5;&#x8BE2;&#x901A;&#x77E5;&#x662F;&#x5426;&#x6388;&#x6743;&#x3002;</td>
</tr>
<tr>
<td style="text-align:left">requestEnableNotification(context: UIAbilityContext): Promise<void></void></td>
<td style="text-align:left">&#x8BF7;&#x6C42;&#x53D1;&#x9001;&#x901A;&#x77E5;&#x7684;&#x8BB8;&#x53EF;&#xFF0C;&#x7B2C;&#x4E00;&#x6B21;&#x8C03;&#x7528;&#x4F1A;&#x5F39;&#x7A97;&#x8BA9;&#x7528;&#x6237;&#x9009;&#x62E9;&#x3002;</td>
</tr>
</tbody>
</table>
<h2 id="&#x5F00;&#x53D1;&#x6B65;&#x9AA4;">&#x5F00;&#x53D1;&#x6B65;&#x9AA4;</h2>
<p>1.&#x5BFC;&#x5165;NotificationManager&#x6A21;&#x5757;&#x3002;</p>
<pre><code class="lang-js"><span class="hljs-keyword">import</span> { notificationManager } <span class="hljs-keyword">from</span> <span class="hljs-string">&apos;@kit.NotificationKit&apos;</span>;
<span class="hljs-keyword">import</span> { BusinessError } <span class="hljs-keyword">from</span> <span class="hljs-string">&apos;@kit.BasicServicesKit&apos;</span>;
<span class="hljs-keyword">import</span> { hilog } <span class="hljs-keyword">from</span> <span class="hljs-string">&apos;@kit.PerformanceAnalysisKit&apos;</span>;
<span class="hljs-keyword">import</span> { common } <span class="hljs-keyword">from</span> <span class="hljs-string">&apos;@kit.AbilityKit&apos;</span>;

<span class="hljs-keyword">const</span> TAG: string = <span class="hljs-string">&apos;[PublishOperation]&apos;</span>;
<span class="hljs-keyword">const</span> DOMAIN_NUMBER: number = <span class="hljs-number">0xFF00</span>;
</code></pre>
<p>2.&#x8BF7;&#x6C42;&#x901A;&#x77E5;&#x6388;&#x6743;&#x3002;</p>
<p>&#x53EF;&#x901A;&#x8FC7;requestEnableNotification&#x7684;&#x9519;&#x8BEF;&#x7801;&#x5224;&#x65AD;&#x7528;&#x6237;&#x662F;&#x5426;&#x6388;&#x6743;&#x3002;&#x82E5;&#x8FD4;&#x56DE;&#x7684;&#x9519;&#x8BEF;&#x7801;&#x4E3A;1600004&#xFF0C;&#x5373;&#x4E3A;&#x62D2;&#x7EDD;&#x6388;&#x6743;&#x3002;</p>
<pre><code class="lang-js"><span class="hljs-keyword">let</span> context = <span class="hljs-keyword">this</span>.getUIContext().getHostContext() <span class="hljs-keyword">as</span> common.UIAbilityContext;
notificationManager.isNotificationEnabled().then((data: boolean) =&gt; {
  hilog.info(DOMAIN_NUMBER, TAG, <span class="hljs-string">&quot;isNotificationEnabled success, data: &quot;</span> + <span class="hljs-built_in">JSON</span>.stringify(data));
  <span class="hljs-keyword">if</span>(!data){
    notificationManager.requestEnableNotification(context).then(() =&gt; {
      hilog.info(DOMAIN_NUMBER, TAG, <span class="hljs-string">`[ANS] requestEnableNotification success`</span>);
    }).catch((err : BusinessError) =&gt; {
      <span class="hljs-keyword">if</span>(<span class="hljs-number">1600004</span> == err.code){
        hilog.error(DOMAIN_NUMBER, TAG, <span class="hljs-string">`[ANS] requestEnableNotification refused, code is <span class="hljs-subst">${err.code}</span>, message is <span class="hljs-subst">${err.message}</span>`</span>);
      } <span class="hljs-keyword">else</span> {
        hilog.error(DOMAIN_NUMBER, TAG, <span class="hljs-string">`[ANS] requestEnableNotification failed, code is <span class="hljs-subst">${err.code}</span>, message is <span class="hljs-subst">${err.message}</span>`</span>);
      }
    });
  }
}).catch((err : BusinessError) =&gt; {
    hilog.error(DOMAIN_NUMBER, TAG, <span class="hljs-string">`isNotificationEnabled fail, code is <span class="hljs-subst">${err.code}</span>, message is <span class="hljs-subst">${err.message}</span>`</span>);
});
</code></pre>
<h3 id="7&#x5B8C;&#x6574;&#x7684;&#x4EE3;&#x7801;">7.&#x5B8C;&#x6574;&#x7684;&#x4EE3;&#x7801;</h3>
<pre><code class="lang-js"><span class="hljs-keyword">import</span> {
  FlutterPlugin,
  FlutterPluginBinding,
  MethodCall,
  MethodCallHandler,
  MethodChannel,
  MethodResult,
} <span class="hljs-keyword">from</span> <span class="hljs-string">&apos;@ohos/flutter_ohos&apos;</span>;
<span class="hljs-keyword">import</span> { BusinessError } <span class="hljs-keyword">from</span> <span class="hljs-string">&apos;@kit.BasicServicesKit&apos;</span>;
<span class="hljs-keyword">import</span> { notificationManager } <span class="hljs-keyword">from</span> <span class="hljs-string">&apos;@kit.NotificationKit&apos;</span>;
<span class="hljs-keyword">import</span> { hilog } <span class="hljs-keyword">from</span> <span class="hljs-string">&apos;@kit.PerformanceAnalysisKit&apos;</span>;
<span class="hljs-keyword">import</span> { common } <span class="hljs-keyword">from</span> <span class="hljs-string">&apos;@kit.AbilityKit&apos;</span>;
<span class="hljs-keyword">import</span> { AbilityAware, AbilityPluginBinding } <span class="hljs-keyword">from</span> <span class="hljs-string">&apos;@ohos/flutter_ohos&apos;</span>;

<span class="hljs-keyword">const</span> TAG: string = <span class="hljs-string">&apos;[PublishOperation]&apos;</span>;
<span class="hljs-keyword">const</span> DOMAIN_NUMBER: number = <span class="hljs-number">0xFF00</span>;

<span class="hljs-comment">/** FlutterAppIconBadgePlugin **/</span>
<span class="hljs-keyword">export</span> <span class="hljs-keyword">default</span> <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">FlutterAppIconBadgePlugin</span> <span class="hljs-title">implements</span> <span class="hljs-title">FlutterPlugin</span>, <span class="hljs-title">MethodCallHandler</span>, <span class="hljs-title">AbilityAware</span> </span>{
  private channel: MethodChannel | <span class="hljs-literal">null</span> = <span class="hljs-literal">null</span>;
  private <span class="hljs-keyword">static</span> _context: common.UIAbilityContext | <span class="hljs-literal">null</span> = <span class="hljs-literal">null</span>;

  <span class="hljs-keyword">constructor</span>() {
  }


  <span class="hljs-keyword">static</span> get context(): common.Context | <span class="hljs-literal">null</span> {
    <span class="hljs-keyword">return</span> FlutterAppIconBadgePlugin._context;
  }

  get context(): common.UIAbilityContext | <span class="hljs-literal">null</span> {
    <span class="hljs-keyword">return</span> FlutterAppIconBadgePlugin._context;
  }

  getUniqueClassName(): string {
    <span class="hljs-keyword">return</span> <span class="hljs-string">&quot;FlutterAppIconBadgePlugin&quot;</span>
  }


  onAttachedToAbility(binding: AbilityPluginBinding): <span class="hljs-keyword">void</span> {
    FlutterAppIconBadgePlugin._context = binding.getAbility().context;
    <span class="hljs-comment">// Called when the plugin is attached to an Ability.</span>
  }

  onDetachedFromAbility(): <span class="hljs-keyword">void</span> {
    <span class="hljs-comment">// this._uiContext = null;</span>
  }

  onAttachedToEngine(binding: FlutterPluginBinding): <span class="hljs-keyword">void</span> {
    <span class="hljs-keyword">this</span>.channel = <span class="hljs-keyword">new</span> MethodChannel(binding.getBinaryMessenger(), <span class="hljs-string">&quot;flutter_app_icon_badge&quot;</span>);
    <span class="hljs-keyword">this</span>.channel.setMethodCallHandler(<span class="hljs-keyword">this</span>)
  }

  onDetachedFromEngine(binding: FlutterPluginBinding): <span class="hljs-keyword">void</span> {
    <span class="hljs-keyword">if</span> (<span class="hljs-keyword">this</span>.channel != <span class="hljs-literal">null</span>) {
      <span class="hljs-keyword">this</span>.channel.setMethodCallHandler(<span class="hljs-literal">null</span>)
    }
  }

  onMethodCall(call: MethodCall, result: MethodResult): <span class="hljs-keyword">void</span> {
    <span class="hljs-keyword">if</span> (call.method == <span class="hljs-string">&quot;updateBadge&quot;</span>) {


      <span class="hljs-keyword">if</span> (FlutterAppIconBadgePlugin._context) { <span class="hljs-comment">// Add null check here</span>
        <span class="hljs-keyword">try</span> {
          notificationManager.isNotificationEnabled().then((data: boolean) =&gt; {
            hilog.info(DOMAIN_NUMBER, TAG, <span class="hljs-string">&quot;isNotificationEnabled success, data: &quot;</span> + <span class="hljs-built_in">JSON</span>.stringify(data));

            <span class="hljs-keyword">try</span> {
              <span class="hljs-comment">// &#x83B7;&#x53D6;&#x53C2;&#x6570;</span>
              <span class="hljs-keyword">const</span> countArg: string = call.argument(<span class="hljs-string">&quot;count&quot;</span>);

              <span class="hljs-keyword">if</span> (countArg === <span class="hljs-literal">null</span> || countArg === <span class="hljs-literal">undefined</span>) {
                <span class="hljs-built_in">console</span>.error(<span class="hljs-string">&apos;Badge count argument is missing.&apos;</span>);
                result.error(<span class="hljs-string">&quot;MISSING_ARGUMENT&quot;</span>, <span class="hljs-string">&quot;Badge count argument is required.&quot;</span>, <span class="hljs-literal">null</span>);
                <span class="hljs-keyword">return</span>;
              }

              <span class="hljs-comment">// &#x786E;&#x4FDD; countArg &#x662F;&#x6570;&#x5B57;&#x7C7B;&#x578B;</span>
              <span class="hljs-keyword">let</span> badgeNumber: number = <span class="hljs-built_in">Number</span>(countArg);

              <span class="hljs-keyword">if</span> (<span class="hljs-built_in">isNaN</span>(badgeNumber)) {
                <span class="hljs-built_in">console</span>.error(<span class="hljs-string">&apos;Invalid badge number received:&apos;</span>, countArg);
                result.error(<span class="hljs-string">&quot;INVALID_ARGUMENT&quot;</span>, <span class="hljs-string">&quot;Badge count must be a number.&quot;</span>, <span class="hljs-literal">null</span>);
                <span class="hljs-keyword">return</span>;
              }

              notificationManager.setBadgeNumber(badgeNumber).then(() =&gt; {
                <span class="hljs-built_in">console</span>.info(<span class="hljs-string">`Succeeded in setting badge number to <span class="hljs-subst">${badgeNumber}</span>.`</span>);
                result.success(<span class="hljs-literal">null</span>);
              }).catch((err: BusinessError) =&gt; {
                <span class="hljs-built_in">console</span>.error(<span class="hljs-string">`Failed to set badge number. Code is <span class="hljs-subst">${err.code}</span>, message is <span class="hljs-subst">${err.message}</span>`</span>);
                result.error(err.code.toString(), err.message, <span class="hljs-literal">null</span>);
              });
            } <span class="hljs-keyword">catch</span> (e) {
              <span class="hljs-keyword">const</span> error = e <span class="hljs-keyword">as</span> <span class="hljs-built_in">Error</span>;
              <span class="hljs-built_in">console</span>.error(<span class="hljs-string">`Error processing updateBadge: <span class="hljs-subst">${error.message}</span>`</span>);
              result.error(<span class="hljs-string">&quot;UNKNOWN_ERROR&quot;</span>, error.message, <span class="hljs-literal">null</span>);
            }

            <span class="hljs-keyword">if</span> (!data) {
              notificationManager.requestEnableNotification(FlutterAppIconBadgePlugin._context).then(() =&gt; {
                hilog.info(DOMAIN_NUMBER, TAG, <span class="hljs-string">`[ANS] requestEnableNotification success`</span>);
              }).catch((err: BusinessError) =&gt; {
                <span class="hljs-keyword">if</span> (<span class="hljs-number">1600004</span> == err.code) {
                  hilog.error(DOMAIN_NUMBER, TAG,
                    <span class="hljs-string">`[ANS] requestEnableNotification refused, code is <span class="hljs-subst">${err.code}</span>, message is <span class="hljs-subst">${err.message}</span>`</span>);
                } <span class="hljs-keyword">else</span> {
                  hilog.error(DOMAIN_NUMBER, TAG,
                    <span class="hljs-string">`[ANS] requestEnableNotification failed, code is <span class="hljs-subst">${err.code}</span>, message is <span class="hljs-subst">${err.message}</span>`</span>);
                }
              });
            }
          }).catch((err: BusinessError) =&gt; {
            hilog.error(DOMAIN_NUMBER, TAG,
              <span class="hljs-string">`isNotificationEnabled fail, code is <span class="hljs-subst">${err.code}</span>, message is <span class="hljs-subst">${err.message}</span>`</span>);
          });
        } <span class="hljs-keyword">catch</span> (err) {
          <span class="hljs-comment">// &#x6355;&#x83B7;&#x540C;&#x6B65;&#x7684;&#x53C2;&#x6570;&#x9519;&#x8BEF;</span>
          <span class="hljs-keyword">let</span> code = (err <span class="hljs-keyword">as</span> BusinessError).code;
          <span class="hljs-keyword">let</span> message = (err <span class="hljs-keyword">as</span> BusinessError).message;
          <span class="hljs-built_in">console</span>.error(<span class="hljs-string">`terminateSelf failed, code is <span class="hljs-subst">${code}</span>, message is <span class="hljs-subst">${message}</span>`</span>);
          result.error(<span class="hljs-string">&quot;TERMINATE_ERROR&quot;</span>, <span class="hljs-string">`terminateSelf error: <span class="hljs-subst">${message}</span>`</span>, <span class="hljs-literal">null</span>);
        }
      } <span class="hljs-keyword">else</span> {
        <span class="hljs-built_in">console</span>.error(<span class="hljs-string">&quot;UIContext is null, cannot terminate self.&quot;</span>);
        result.error(<span class="hljs-string">&quot;CONTEXT_NULL&quot;</span>, <span class="hljs-string">&quot;UIContext is null&quot;</span>, <span class="hljs-literal">null</span>); <span class="hljs-comment">// Inform Flutter about the error</span>
      }

    } <span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> (call.method == <span class="hljs-string">&quot;removeBadge&quot;</span>) {
      <span class="hljs-keyword">try</span> {
        notificationManager.setBadgeNumber(<span class="hljs-number">0</span>).then(() =&gt; {
          <span class="hljs-built_in">console</span>.info(<span class="hljs-string">`Succeeded in removing badge number.`</span>);
          result.success(<span class="hljs-literal">null</span>);
        }).catch((err: BusinessError) =&gt; {
          <span class="hljs-built_in">console</span>.error(<span class="hljs-string">`Failed to remove badge number. Code is <span class="hljs-subst">${err.code}</span>, message is <span class="hljs-subst">${err.message}</span>`</span>);
          result.error(err.code.toString(), err.message, <span class="hljs-literal">null</span>);
        });
      } <span class="hljs-keyword">catch</span> (e) {
        <span class="hljs-keyword">const</span> error = e <span class="hljs-keyword">as</span> <span class="hljs-built_in">Error</span>;
        <span class="hljs-built_in">console</span>.error(<span class="hljs-string">`Error processing removeBadge: <span class="hljs-subst">${error.message}</span>`</span>);
        result.error(<span class="hljs-string">&quot;UNKNOWN_ERROR&quot;</span>, error.message, <span class="hljs-literal">null</span>);
      }
    } <span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> (call.method == <span class="hljs-string">&quot;isAppBadgeSupported&quot;</span>) {
      <span class="hljs-comment">// &#x9E3F;&#x8499;&#x5E73;&#x53F0;&#x9ED8;&#x8BA4;&#x652F;&#x6301;&#x89D2;&#x6807;</span>
      result.success(<span class="hljs-literal">true</span>);
    } <span class="hljs-keyword">else</span> {
      result.notImplemented();
    }
  }
}
</code></pre>
<h2 id="&#x56DB;&#x3001;&#x7F16;&#x5199;-example">&#x56DB;&#x3001;&#x7F16;&#x5199; Example</h2>
<h4 id="1-&#x521B;&#x5EFA;-example-&#x5E94;&#x7528;">1. &#x521B;&#x5EFA; Example &#x5E94;&#x7528;</h4>
<p>&#x5728;&#x63D2;&#x4EF6;&#x6839;&#x76EE;&#x5F55;&#x4E0B;&#x521B;&#x5EFA;&#x4E00;&#x4E2A;&#x540D;&#x4E3A; <code>example</code> &#x7684;&#x6587;&#x4EF6;&#x5939;&#xFF0C;&#x7528;&#x4E8E;&#x5B58;&#x653E;&#x793A;&#x4F8B;&#x5E94;&#x7528;&#x3002;&#x5728; <code>example</code> &#x6587;&#x4EF6;&#x5939;&#x4E2D;&#xFF0C;&#x521B;&#x5EFA;&#x4E00;&#x4E2A;&#x9E3F;&#x8499;&#x5E73;&#x53F0;&#x7684; Flutter &#x5E94;&#x7528;&#xFF0C;&#x7528;&#x4E8E;&#x9A8C;&#x8BC1;&#x63D2;&#x4EF6;&#x529F;&#x80FD;&#x3002;</p>
<h4 id="2-&#x7B7E;&#x540D;&#x4E0E;&#x8FD0;&#x884C;">2. &#x7B7E;&#x540D;&#x4E0E;&#x8FD0;&#x884C;</h4>
<p>&#x4F7F;&#x7528; <code>Deveco Studio</code> &#x6253;&#x5F00; <code>example &gt; ohos</code> &#x76EE;&#x5F55;&#xFF0C;&#x5355;&#x51FB; <code>File &gt; Project Structure &gt; Project &gt; Signing Configs</code>&#xFF0C;&#x52FE;&#x9009; <code>Automatically generate signature</code>&#xFF0C;&#x7B49;&#x5F85;&#x81EA;&#x52A8;&#x7B7E;&#x540D;&#x5B8C;&#x6210;&#x3002;&#x7136;&#x540E;&#x8FD0;&#x884C;&#x4EE5;&#x4E0B;&#x547D;&#x4EE4;&#xFF1A;</p>
<pre><code>flutter pub get

 flutter build hap --debug
</code></pre><p>&#x5982;&#x679C;&#x5E94;&#x7528;&#x6B63;&#x5E38;&#x542F;&#x52A8;&#xFF0C;&#x8BF4;&#x660E;&#x63D2;&#x4EF6;&#x9002;&#x914D;&#x6210;&#x529F;&#x3002;&#x5982;&#x679C;&#x6CA1;&#x6709;&#xFF0C;&#x6B22;&#x8FCE;&#x5927;&#x5BB6;&#x8054;&#x7CFB;&#x575A;&#x679C;&#x6D3E;&#x4E00;&#x8D77;&#x652F;&#x6301;&#x3002;</p>
<h2 id="&#x4E94;&#x3001;&#x603B;&#x7ED3;">&#x4E94;&#x3001;&#x603B;&#x7ED3;</h2>
<p>&#x901A;&#x8FC7;&#x4EE5;&#x4E0A;&#x6B65;&#x9AA4;&#xFF0C;&#x6211;&#x4EEC;&#x6210;&#x529F;&#x5730;&#x5C06; flutter_app_icon_badge &#x4E09;&#x65B9;&#x5E93;&#x9002;&#x914D;&#x5230;&#x4E86;&#x9E3F;&#x8499;&#x5E73;&#x53F0;&#x3002;&#x8FD9;&#x4E2A;&#x8FC7;&#x7A0B;&#x6D89;&#x53CA;&#x5230;&#x4E86;&#x89E3;&#x63D2;&#x4EF6;&#x7684;&#x57FA;&#x672C;&#x4FE1;&#x606F;&#x3001;&#x914D;&#x7F6E;&#x5F00;&#x53D1;&#x73AF;&#x5883;&#x3001;&#x521B;&#x5EFA;&#x9E3F;&#x8499;&#x6A21;&#x5757;&#x3001;&#x7F16;&#x5199;&#x539F;&#x751F;&#x4EE3;&#x7801;&#x4EE5;&#x53CA;&#x6D4B;&#x8BD5;&#x9A8C;&#x8BC1;&#x7B49;&#x591A;&#x4E2A;&#x73AF;&#x8282;&#x3002;&#x5E0C;&#x671B;&#x8FD9;&#x7BC7;&#x535A;&#x5BA2;&#x80FD;&#x591F;&#x5E2E;&#x52A9;&#x5230;&#x9700;&#x8981;&#x8FDB;&#x884C; flutter_app_icon_badge &#x9E3F;&#x8499;&#x9002;&#x914D;&#x7684;&#x5F00;&#x53D1;&#x8005;&#x4EEC;&#xFF0C;&#x8BA9;&#x5927;&#x5BB6;&#x5728;&#x9E3F;&#x8499;&#x751F;&#x6001;&#x7684;&#x5F00;&#x53D1;&#x4E2D;&#x66F4;&#x52A0;&#x5F97;&#x5FC3;&#x5E94;&#x624B;&#x3002;</p>
<h2 id="&#x516D;&#x3001;&#x53C2;&#x8003;">&#x516D;&#x3001;&#x53C2;&#x8003;</h2>
<ul>
<li><a href="https://gitcode.com/openharmony-sig/flutter_samples/blob/master/ohos/docs/04_development/&#x5982;&#x4F55;&#x4F7F;&#x7528;Flutter&#x4E0E;OpenHarmony&#x901A;&#x4FE1; FlutterChannel.md" target="_blank">&#x5982;&#x4F55;&#x4F7F;&#x7528;Flutter&#x4E0E;OpenHarmony&#x901A;&#x4FE1; FlutterChannel</a></li>
<li><a href="https://gitcode.com/openharmony-sig/flutter_samples/blob/master/ohos/docs/04_development/&#x5982;&#x4F55;&#x4F7F;&#x7528;&#x6DF7;&#x5408;&#x5F00;&#x53D1; module.md" target="_blank">&#x5F00;&#x53D1;module</a></li>
<li><a href="https://gitcode.com/openharmony-sig/flutter_samples/blob/master/ohos/docs/04_development/&#x5F00;&#x53D1;package.md" target="_blank">&#x5F00;&#x53D1;package</a></li>
<li><a href="https://gitcode.com/openharmony-sig/flutter_samples/blob/master/ohos/docs/04_development/&#x5F00;&#x53D1;plugin.md" target="_blank">&#x5F00;&#x53D1;plugin</a></li>
<li><a href="https://gitcode.com/openharmony-sig/flutter_samples/blob/master/ohos/docs/04_development/&#x5F00;&#x53D1;FFI plugin.md" target="_blank">&#x5F00;&#x53D1;FFI plugin</a></li>
<li><a href="https://docs.flutter.cn/packages-and-plugins/developing-packages" target="_blank">developing-packages</a></li>
<li><a href="https://gitcode.com/nutpi/flutter_app_icon_badge" target="_blank">&#x9002;&#x914D;&#x4ED3;&#x5E93;&#x5730;&#x5740;</a></li>
</ul>
<h2 id="&#x4E03;&#x3001;&#x575A;&#x679C;&#x6D3E;">&#x4E03;&#x3001;&#x575A;&#x679C;&#x6D3E;</h2>
<p>&#x575A;&#x679C;&#x6D3E;&#x7531;&#x575A;&#x679C;&#x7B49;&#x4EBA;&#x521B;&#x5EFA;&#xFF0C;&#x56E2;&#x961F;&#x62E5;&#x6709;&#x82E5;&#x5E72;&#x534E;&#x4E3A;HDE&#xFF0C;&#x4EE5;&#x53CA;&#x82E5;&#x5E72;&#x5176;&#x4ED6;&#x9886;&#x57DF;&#x7684;&#x4E09;&#x5341;&#x4F59;&#x4F4D;&#x4E07;&#x7C89;&#x535A;&#x4E3B;&#x8FD0;&#x8425;&#x3002;&#x4E13;&#x6CE8;&#x4E8E;&#x5206;&#x4EAB;&#x7684;&#x6280;&#x672F;&#x5305;&#x62EC;HarmonyOS/OpenHarmony&#xFF0C;ArkUI-X&#xFF0C;&#x5143;&#x670D;&#x52A1;&#xFF0C;&#x670D;&#x52A1;&#x5361;&#x7247;&#xFF0C;&#x534E;&#x4E3A;&#x81EA;&#x7814;&#x8BED;&#x8A00;&#xFF0C;BlueOS&#x64CD;&#x4F5C;&#x7CFB;&#x7EDF;&#x3001;&#x56E2;&#x961F;&#x6210;&#x5458;&#x805A;&#x96C6;&#x5728;&#x5317;&#x4EAC;&#x3001;&#x4E0A;&#x6D77;&#x3001;&#x5E7F;&#x5DDE;&#x3001;&#x6DF1;&#x5733;&#x3001;&#x5357;&#x4EAC;&#x3001;&#x676D;&#x5DDE;&#x3001;&#x82CF;&#x5DDE;&#x3001;&#x5B81;&#x590F;&#x7B49;&#x5730;&#x3002; &#x805A;&#x7126;&#x201C;&#x9E3F;&#x8499;&#x539F;&#x751F;&#x5E94;&#x7528;&#x201D;&#x3001;&#x201C;&#x667A;&#x80FD;&#x7269;&#x8054;&#x201D;&#x548C;&#x201C;AI&#x8D4B;&#x80FD;&#x201D;&#x3001;&#x201C;&#x4EBA;&#x5DE5;&#x667A;&#x80FD;&#x201D;&#x56DB;&#x5927;&#x4E1A;&#x52A1;&#x9886;&#x57DF;&#xFF0C;&#x4F9D;&#x6258;&#x534E;&#x4E3A;&#x5F00;&#x53D1;&#x8005;&#x4E13;&#x5BB6;&#x7B49;&#x5F3A;&#x5927;&#x7684;&#x6280;&#x672F;&#x56E2;&#x961F;&#xFF0C;&#x4EE5;&#x53CA;&#x6DB5;&#x76D6;&#x9700;&#x6C42;&#x3001;&#x5F00;&#x53D1;&#x3001;&#x6D4B;&#x8BD5;&#x3001;&#x8FD0;&#x7EF4;&#x4E8E;&#x4E00;&#x4F53;&#x7684;&#x7EFC;&#x5408;&#x670D;&#x52A1;&#x4F53;&#x7CFB;&#xFF0C;&#x8D4B;&#x80FD;&#x6587;&#x65C5;&#x3001;&#x5A92;&#x4F53;&#x3001;&#x793E;&#x4EA4;&#x3001;&#x5BB6;&#x5C45;&#x3001;&#x6D88;&#x8D39;&#x7535;&#x5B50;&#x7B49;&#x884C;&#x4E1A;&#x5BA2;&#x6237;&#xFF0C;&#x6EE1;&#x8DB3;&#x793E;&#x533A;&#x5BA2;&#x6237;&#x6570;&#x5B57;&#x5316;&#x5347;&#x7EA7;&#x8F6C;&#x578B;&#x7684;&#x9700;&#x6C42;&#xFF0C;&#x5E2E;&#x52A9;&#x5BA2;&#x6237;&#x5B9E;&#x73B0;&#x4EF7;&#x503C;&#x63D0;&#x5347;&#x3002; &#x76EE;&#x524D;&#x4E0A;&#x67B6;&#x9E3F;&#x8499;&#x539F;&#x751F;&#x5E94;&#x7528;18&#x6B3E;&#xFF0C;&#x4E09;&#x65B9;&#x5E93;72&#x4E2A;&#x3002;</p>
<p>&#x5730;&#x5740;&#xFF1A;<a href="https://atomgit.com/nutpi" target="_blank">https://atomgit.com/nutpi</a></p>
<p><a href="https://gitcode.com/nutpi" target="_blank">https://gitcode.com/nutpi</a></p>
<h2 id="&#x516B;&#x3001;faq">&#x516B;&#x3001;FAQ</h2>
<p>&#x5728;&#x521A;&#x5F00;&#x59CB;&#x9002;&#x914D;&#x5B8C;&#x6210;&#x540E;&#xFF0C;&#x5E76;&#x6CA1;&#x6709;&#x6210;&#x529F;&#x5728;&#x684C;&#x9762;&#x4E0A;&#x751F;&#x6210;&#x89D2;&#x6807;&#xFF0C;&#x539F;&#x56E0;&#x662F;&#x6CA1;&#x6709;&#x7533;&#x8BF7;&#x6743;&#x9650;&#x3002;&#x6240;&#x4EE5;&#x9700;&#x8981;&#x8BB0;&#x5F97;&#x6DFB;&#x52A0;&#x6743;&#x9650;&#x3002;</p>
<footer class="page-footer"><span class="copyright">powered by Gitbook</span><span class="footer-modification">&#x8BE5;&#x6587;&#x4EF6;&#x4FEE;&#x8BA2;&#x65F6;&#x95F4;&#xFF1A;
2025-09-04 08:17:16
</span></footer>
<script>console.log("plugin-popup....");document.onclick = function(e){ e.target.tagName === "IMG" && window.open(e.target.src,e.target.src)}</script><style>img{cursor:pointer}</style> 
          </section>
          
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>
 
          <div class="book-footer">
            
            <div class="donate">
              <div></div>
              <button class="donate-btn" onclick="showModal()">赞赏</button>
            </div>
             
            <div class="copyright"></div>
            
          </div>
          
        </div>
      </div>
      
    </div>

     
    <a
      href="12.12适配battey_level_plus.html"
      class="navigation navigation-prev "
      aria-label="Previous page: 13.15适配battey_level_plus"
    >
      <i class="fa fa-angle-left"></i>
    </a>
     
    <a
      href="12.14适配flutter_native_contact_picker_plus.html"
      class="navigation navigation-next "
      aria-label="Next page: 13.17适配flutter_native_contact_picker_plus"
    >
      <i class="fa fa-angle-right"></i>
    </a>
      
  </div>
  <script>
    function showModal() {
      document.getElementsByClassName("mask")[0].style.display = "block";
      document.getElementsByClassName("donate-modal")[0].style.display =
        "block";
    }
    // 切换赞赏码
    function showDonateImg(num) {
      let alipay = "";
      let wxpay = ""
      if(num){
        wxpay = "hidden"
      }else{
        alipay = "hidden"
      }
      document.getElementById("wxpay-code").hidden = wxpay;
      document.getElementById("alipay-code").hidden = alipay;
      document.getElementsByName("pay-way")[num].checked = "checked";
    }

    // 关闭赞赏框
    function closeDonateModal() {
      document.getElementsByClassName("mask")[0].style.display = "none";
      document.getElementsByClassName("donate-modal")[0].style.display = "none";
    }

    var gitbook = gitbook || [];
    gitbook.push(function () {
      gitbook.page.hasChanged({"page":{"title":"13.16适配flutter_badge_plus","level":"1.13.16","depth":2,"next":{"title":"13.17适配flutter_native_contact_picker_plus","level":"1.13.17","depth":2,"path":"chapter12/12.14适配flutter_native_contact_picker_plus.md","ref":"./chapter12/12.14适配flutter_native_contact_picker_plus.md","articles":[]},"previous":{"title":"13.15适配battey_level_plus","level":"1.13.15","depth":2,"path":"chapter12/12.12适配battey_level_plus.md","ref":"./chapter12/12.12适配battey_level_plus.md","articles":[]},"dir":"ltr"},"config":{"plugins":["edit-link","splitter","tbfed-pagefooter","expandable-chapters","chapter-fold","back-to-top-button","code","pageview-count","popup","search-plus","-lunr","-search","-sharing","sharing-plus","theme-lou","emphasize","livereload","gitcode-issue-feedback","forkmegithub","livereload"],"root":".","styles":{"website":"styles/website.css"},"pluginsConfig":{"tbfed-pagefooter":{"modify_label":"该文件修订时间：","modify_format":"YYYY-MM-DD HH:mm:ss"},"chapter-fold":{},"pluginsConfig":{"expandable-chapters":{}},"emphasize":{},"livereload":{},"gitcode-issue-feedback":{"repo":"nutpi/gitbook-harmonyos-flutter"},"splitter":{},"readmore":{"blogId":"27976-1678928361372-483","name":"坚果派","qrcode":"https://luckly007.oss-cn-beijing.aliyuncs.com/images/image-20230316085818226.png","keyword":"鸿蒙坚果"},"sharing-plus":{"qq":false,"all":["facebook","google","twitter","instapaper","linkedin","pocket","stumbleupon"],"douban":false,"facebook":true,"weibo":false,"instapaper":false,"whatsapp":false,"hatenaBookmark":false,"twitter":true,"messenger":false,"line":false,"vk":false,"pocket":true,"google":false,"viber":false,"stumbleupon":false,"qzone":false,"linkedin":false},"popup":{},"code":{"copyButtons":true},"theme-lou":{"hide-elements":[".summary .gitbook-link",".summary .divider"],"color":"#FF4848","book-anchor-title":"本章目录","copyright":{"author":"vx:nut_pie"},"forbidCopy":true,"logo":"assets/avatar.png","book-summary-title":"文章目录","search-placeholder":"输入关键字搜索","copyrightLogo":"assets/copyright.png","favicon":"assets/avatar.png","appleTouchIconPrecomposed152":"assets/avatar.png"},"changyan":{"appid":"cyvHoCPAs","conf":"0440cfc4168ba95d73cfc52dd4d5c60b"},"fontsettings":{"theme":"white","family":"sans","size":2},"highlight":{},"back-to-top-button":{},"pageview-count":{},"sharing":{"qq":false,"all":["qq","qzone","whatsapp","douban","facebook","google","instapaper","linkedin","messenger","twitter","weibo"],"douban":false,"facebook":false,"weibo":false,"twitter":false,"pocket":false,"google":false,"qzone":false},"edit-link":{"label":"编辑此页","base":"https://gitcode.com/nutpi/gitbook-harmonyos-flutter/edit/master/"},"forkmegithub":{"color":"gray","url":"https://gitcode.com/nutpi/gitbook-harmonyos-flutter/fork/create"},"theme-default":{"styles":{"pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css","website":"styles/website.css"},"showLevel":false},"expandable-chapters":{},"search-plus":{}},"theme":"default","author":"坚果派","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{"themeLou":{"nav":[{"target":"_blank","url":"https://www.nutpi.net/","name":"坚果派官网"},{"target":"_blank","url":"https://www.arkui.club/","name":"ArkUI实战"},{"target":"_blank","url":"https://space.bilibili.com/480883651","name":"哔哩哔哩"},{"target":"_blank","url":"https://gitcode.com/nutpi","name":"GitCode"}],"footer":{"donate":{"wechat":"https://luckly007.oss-cn-beijing.aliyuncs.com/img/image-20210922202901895.png","message":"随意打赏，但不要超过一顿早餐钱 💕","wxpay":"https://luckly007.oss-cn-beijing.aliyuncs.com/img/image-20210922202901895.png","alipay":"https://luckly007.oss-cn-beijing.aliyuncs.com/img/image-20210922202843746.png","nickname":"breeze","button":"打赏","wechatText":"微信","alipayText":"支付宝","title":"『赠人玫瑰 🌹 手有余香 』","avatar":"http://xkapp-uat.oss-cn-hangzhou.aliyuncs.com/2e7a3f70-80ab-4b50-93ec-a04dfeef949b/avatar-100.png"},"copyright":true}}},"title":"Flutter for Harmony教程","language":"zh-hans","gitbook":"*","description":"Flutter for Harmony电子书教程"},"file":{"path":"chapter12/12.13适配flutter_badge_plus.md","mtime":"2025-09-04T00:17:16.190Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2025-09-14T05:25:49.343Z"},"basePath":"..","book":{"language":""}});
    });
  </script>
</div>

        
    <script src="../gitbook/gitbook.js"></script>
    <script src="../gitbook/theme.js"></script>
    
        
        <script src="../gitbook/gitbook-plugin-edit-link/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-splitter/splitter.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-expandable-chapters/expandable-chapters.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-chapter-fold/chapter-fold.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-back-to-top-button/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-code/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-pageview-count/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search-plus/jquery.mark.min.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search-plus/search.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-sharing-plus/buttons.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-livereload/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-gitcode-issue-feedback/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-forkmegithub/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-theme-lou/jweixin-1.6.0.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-theme-lou/lou.js"></script>
        
    

    </body>
</html>

